【问题标题】:Nativescript - unlaod frameNativescript - 卸载框架
【发布时间】:2019-01-18 08:06:52
【问题描述】:

我想问以下问题: 我有 2 个主框架; app-root 和仪表板。

app.js:

if (LS.getItem('Bearer') != null) {
application.run({ moduleName: "dashboard/root" });
} else {
 application.run({ moduleName: "app-root" });
}

app-root.hxml

<Frame defaultPage="login/login" id="app-root"></Frame>

app.root 是第一帧,它包含登录和注册页面。

仪表板框架:

登录页面有登录按钮,点击加载仪表板页面

var frameModule = require('ui/frame');
frameModule.topmost().navigate("dashboard/root");

现在,仪表板框架已加载。仪表板框架有一些底部导航,每个都存在并用作页面之间的导航。

我在仪表板中也有注销按钮,用于清除一些数据,然后导航到登录页面。

现在我的问题/问题是 - > 在登录页面中,我在此页面中看到仪表板的按钮导航,这意味着我猜我做错了什么。我假设主框架是仪表板,但为什么不是登录页面?在导航到登录页面之前,有没有办法“卸载”仪表板框架?当然,如果我关闭应用程序并再次运行,logijn 页面看起来不错,没有任何 dahsboard 的框架元素...

谢谢你的建议。

仪表板:

<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="load" id="test" >
<GridLayout rows="*,60" class="c1" id="nawRows">
<Frame defaultPage="dashboard/dashboard/dashboard/" id="dashboard" class="c2"></Frame>
<GridLayout row="1" class="xx">
    <StackLayout verticalAlignment="bottom" row="2" class="bottom-nav">
        <GridLayout rows="*" columns="*,*,*,*,*,*" height="70" id="main-ic0">
            <Label class="icon0 foot-icon" row="0" col="0" tap="{{ loadPage }}"  data-id="0" id="ico0"></Label>
            <Label class="icon1 foot-icon" row="0" col="1" tap="{{ loadPage }}"  data-id="1" id="ico1"></Label>
            <Label class="icon2 foot-icon" row="0" col="2" tap="{{ loadPage }}"  data-id="2" id="ico2"></Label>
            <Label class="icon3 foot-icon" row="0" col="3" tap="{{ loadPage }}"  data-id="3" id="ico3"></Label>
            <Label class="icon5 foot-icon" row="0" col="4" tap="{{ loadPage }}"  data-id="5" id="ico4"></Label>
            <Label class="icon4 foot-icon" row="0" col="5" tap="{{ loadPage }}"  data-id="4" id="ico5"></Label>
        </GridLayout>
    </StackLayout>
</GridLayout>

【问题讨论】:

  • 你在dashboard-root.xml有什么?

标签: nativescript


【解决方案1】:

我认为在注销时您必须使用错误的框架来导航到登录页面。获取您的 app-root 框架并导航到其中的登录页面。

frame.getFrameById('app-root').navigate('/path/to/login', { clearHistory: true });

【讨论】:

  • 谢谢,会尽力通知你的。但我想我以前做过,但没有用。错误是 - 未找到框架。除此之外,我担心 getFrameById 现在可能会像文档所说的那样工作:“请注意,这会搜索已经导航的框架,并且不会找到尚未显示​​的框架”,但值得检查两次。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-12-03
  • 2016-12-29
  • 1970-01-01
  • 2011-03-08
  • 2017-01-13
  • 1970-01-01
  • 2018-05-25
相关资源
最近更新 更多