如何防止刷新页面移动到离子2/3中的根页面

时间:2018-03-15 12:09:46

标签: javascript angular ionic-framework ionic2 ionic3

我在离子2中创建了更多页面,当我刷新页面时,它总是重定向到根页索引,如何防止它。

实施例

我登录后创建登录页面和欢迎页面如果我按下刷新它会自动移动到根页面作为登录。

3 个答案:

答案 0 :(得分:0)

在本地进行测试(通过ionic serve命令)通常会观察到此行为。我注意到在部署到服务器后情况并非如此。您是否尝试过并再次测试?

答案 1 :(得分:0)

i've manage to find some solution that solve this problem.

As i know and under my understand the ionic framework use the navcontroller state(push, pop) to navigate the page then if we refresh the browser this navcontroller state will gone and then go to the root.

So the solution that i've found is in this Question from stack overflow also. the answer give you 2 choices "LazyLoad" and "Deeplink"

But ive manage to solve my solution with "LazyLoad" Method by given custom ionic page segment name that different from the default. for more informantion is here

答案 2 :(得分:-1)

使用 ionic-CLI 创建项目时,通常在 src / app / app-component.ts 中有一个名为rootPage: any = 'HomePage';的变量

这是您的根页面。如果您想要更改为转到 AuthPage

  rootPage: any = 'AuthPage';

此处 AuthPage 是您的authpage类的名称