gpt4 book ai didi

javascript - 带有 ionic 框架的 angularjs 中的奇怪导航行为

转载 作者:行者123 更新时间:2023-11-28 00:46:39 26 4
gpt4 key购买 nike

演示 http://codepen.io/anon/pen/qEOJBp

我可以通过此链接从第 1 页导航到第 2 页:<a href="#/threadContent">GO</a>

但无法使用 <a href="#/home">Back</a> 从第 2 页返回到第 1 页?我想知道为什么?该代码对我来说看起来完美无缺:

<ion-nav-view name="home"></ion-nav-view>
<ion-nav-view name="threadContent"></ion-nav-view>

<script type="text/ng-template" id="home.html">
<ion-view name="home">
<ion-content>
<h2>Home Page</h2>
<p>Here is the main route for the app.</p>
<a href="#/threadContent">GO</a>
</ion-content>
</ion-view>
</script>

<script type="text/ng-template" id="threadContent.html">
<ion-view name="threadContent" title="Thread Content">
<ion-content>
<a href="#/home">Back</a>
<h2>Using the app</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis architecto hic officia quasi excepturi sequi deleniti maiores consectetur veritatis sint?</p>
</ion-content>
</ion-view>
</script>

最佳答案

我认为如果不需要的话就不应该使用命名 View 。如果我明白你想要什么,你只需要一个<ion-nav-view></ion-nav-view>在您的页面中。

仅当您希望状态修改页面的多个区域时,才需要命名 View 。请参阅ui-router docs for more .

您还必须将默认状态更改为 $urlRouterProvider.otherwise('home'); (不是“/home”)。

这是一个工作代码笔 http://codepen.io/anon/pen/ogjRwP

关于javascript - 带有 ionic 框架的 angularjs 中的奇怪导航行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27294136/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com