zoukankan      html  css  js  c++  java
  • 微信小程序 页面跳转

    本文总结了微信小程序页面跳转分为这几种类型:

    • navigate:跳转页面,并保留当前页面。前一个页面可以使用navigateBack类型的跳转退回。
    • redirect:关闭当前页面,然后跳转到新页面。
    • switchTab:跳转到tabBar页面(在app.json中注册过的tabBar页面),同时关闭其他非tabBar页面。
    • navigateBack:页面退回。

    微信原生提供的API

    navigateTo

    wx.navigateTo({
      url: 'page/home'
    })

    navigateBack

    wx.navigateTo({
     url: 'page/page_a'
    })
    
    wx.navigateTo({
     url: 'page/page_b'
    })
    
    // 跳转到page_a
    wx.navigateBack({
     delta: 2
    })

    redirectTo

    wx.redirectTo({
      url: 'page/home'
    })

    switchTab

    wx.switchTab({
      url: 'page/index/index'
    })

    wxml页面组件跳转

    在wxml使用open-type来设置页面的跳转类型。其中open-type默认值为navigate

    <navigator url="/page/navigate">跳转到新页面</navigator>
    <navigator url="/page/redirect" open-type="redirect">在当前页打开</navigator>
    <navigator url="/page/index" open-type="switchTab">Tab切换</navigator>
    <navigator url="/page/index" open-type="navigateBack">返回/navigator>

    .

  • 相关阅读:
    MyBatis
    JavaAgent
    Intellij IDEA
    SVN安装总结
    git(笔记)
    springboot面试题
    spring总结
    springmvc总结
    jdbc链接数据库
    redis面试题
  • 原文地址:https://www.cnblogs.com/crazycode2/p/9598642.html
Copyright © 2011-2022 走看看