我在 Google 上看到了很多:Ionic
和 Angular
的导览、演练和介绍页面,但我无法追踪它是如何的仅在首次打开该应用时显示(之后,除非您删除该应用,否则不会再次显示)。
所以我想做的是显示我只创建过一次的 View / Controller /页面,并且仅在应用程序第一次打开时显示。第二次访问时,我不想让人们再看到它。
这可能吗?如果是这样,我该怎么做?有人能指出我正确的方向吗?
最佳答案
在你的 Controller 中使用
if(localStorage.getItem['firstTimeLoad']!='TRUE'){
localStorage.setItem['firstTimeLoad']='TRUE';
$state.go('onetime.view');
}
else{
$state.go('your.route');
}
因此,当您的应用首次加载时,您的本地存储将为空。所以它将把你带到你的第一次页面并设置本地存储,这样当你第二次加载应用程序时,条件将不满足。
或
if(localStorage['firstTimeLoad']!='TRUE'){
localStorage['firstTimeLoad']='TRUE';
$state.go('onetime.view');
}
else{
$state.go('your.route');
}
关于javascript - 如何仅在第一次打开应用程序时在 Ionic 中显示 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42659581/