zoukankan      html  css  js  c++  java
  • 微信小程序页面跳转的四种方法

    1.  wx.navigateTo({}) ,保留当前页面,跳转到应用内的某个页面,使用 wx.navigateBack 可以返回;

      示例:

     1 wx.navigateTo({
     2     url:'../test/test?id=1&page=4',  //跳转页面的路径,可带参数 ?隔开,不同参数用 & 分隔;相对路径,不需要.wxml后缀
     3     success:function(){}        //成功后的回调;
     4     fail:function(){}          //失败后的回调;
     5     complete:function(){}      //结束后的回调(成功,失败都会执行)
     6 })
     7 
     8 传递的参数在接收页面onLoad()函数中得到值:option.id就可以得到了
     9 onLoad: function (option) {
        console.log(option)//可以打印一下option看查看参数 10 this.setData({ 11 id:option.id, 12 });

        2.   wx.redirectTo() , 关闭当前页面,跳转到非tabBar的某个页面,

        3. 使用组件  <navigator>  示例:  <navigator url='../test/test'>点击跳转</navigator> 

        4. wx.switchTab ,跳转到tabBar的某个页面,

    1
    2
    3
    wx.switchTab({
          url: '../taste/index',   //注意switchTab只能跳转到带有tab的页面,不能跳转到不带tab的页面
        })
  • 相关阅读:
    寻找大富翁
    C++ STL sort()函数用法
    众数
    平方因子
    Hdu 1089 A+B for Input-Output Practice (I)
    Hdu 1090 A+B for Input-Output Practice (II)
    Hdu 1083 Courses
    Hdu 1069 Monkey and Banana
    Hdu 1062 Text Reverse
    Hdu 1068 Girls and Boys
  • 原文地址:https://www.cnblogs.com/dfsxh/p/10607302.html
Copyright © 2011-2022 走看看