zoukankan      html  css  js  c++  java
  • 小程序页面链接-navigator(导航)

    navigator-页面链接-通过设置open-type的值来确定页面的打开方式

    <view class="btn-area">
    <navigator url="/page/navigate/navigate?title=navigate" hover-class="navigator-hover">跳转到新页面</navigator>
    <navigator url="../../redirect/redirect/redirect?title=redirect" open-type="redirect" hover-class="other-navigator-hover">在当前页打开</navigator>
    <navigator url="/page/index/index" open-type="switchTab" hover-class="other-navigator-hover">切换 Tab</navigator>
    <navigator target="miniProgram" open-type="navigate" app-id="" path="" extra-data="" version="release">打开绑定的小程序</navigator>
    </view>

    open-type 有效值

    navigate 对应 wx.navigateTo 或 wx.navigateToMiniProgram 的功能
    redirect 对应 wx.redirectTo 的功能
    switchTab 对应 wx.switchTab 的功能
    reLaunch 对应 wx.reLaunch 的功能 1.1.0
    navigateBack 对应 wx.navigateBack 的功能 1.1.0
    exit 退出小程序,target="miniProgram"时生效 2.1.0

    重定向、转发等各种跳转的区别如下:

    navigate :用于保留当前页面、跳转到应用内的某个页面,使用 wx.navigateBack可以返回到原页面。对于页面不是特别多的小程序,通常推荐使用 wx.navigateTo进行跳转, 以便返回原页面,以提高加载速度。当页面特别多时,则不推荐使用。

    redirect :当页面过多时,被保留页面会挤占微信分配给小程序的内存,或是达到微信所限制的 5 层页面栈。这时,应该考虑选择 wx.redirectTo。wx.redirectTo()用于关闭当前页面,跳转到应用内的某个页面。这样的跳转,可以避免跳转前页面占据运行内存,但返回时页面需要重新加载,增加了返回页面的显示时间。

    reLaunch : wx.reLaunch()与 wx.redirectTo()的用途基本相同, wx.reLaunch()先关闭了内存中所有保留的页面,再跳转到目标页面

    switchTab : 对于跳转到 tab bar 的页面,最好选择 wx.switchTab(),它会先关闭所有非 tab bar 的页面。其次,也可以选择 wx.reLaunch(),它也能实现从非 tab bar 跳转到 tab bar,或在 tab bar 间跳转,效果等同 wx.switchTab()。使用其他跳转 API 来跳转到 tab bar,则会跳转失败

    navigateBack: 用于关闭当前页面,并返回上一页面或多级页面。开发者可通过 getCurrentPages() 获取当前的页面栈,决定需要返回几层。这个 API 需要填写的参数只有 delta,表示要返回的页面数。若 delta 的取值大于现有可返回页面数时,则返回到用户进入小程序的第一个页面。当不填写 delta 的值时,就默认其为 1(注意,默认并非取 0),即返回上一页面。

  • 相关阅读:
    Ubuntu 查看网关地址方法
    cf451C-Predict Outcome of the Game
    C语言运算符优先级
    文件的概念以及VC里的一些文件操作API简介
    关于空指针NULL、野指针、通用指针
    由字符串常量引发的思考
    数字三角形问题
    cdoj第13th校赛初赛F
    cdoj第13th校赛初赛H
    cdoj第13th校赛初赛L
  • 原文地址:https://www.cnblogs.com/zhoudaozhang/p/9903880.html
Copyright © 2011-2022 走看看