search

Home  >  Q&A  >  body text

javascript - 小程序跳转失败?

     绑定了一个点击事件 
      <view data-idx="{{itemName.mark}}" class="chat-item flex-wrp" wx:for="{{ylInfo}}" wx:for-item="itemName"  bindtap="tiao">跳转<view>
      
      
      下面是事件的内容
      tiao:function(e){
          wx.navigateTo({
                  url: '../index/index',//页面跳转相对路径要写清楚且准确
                  success: function(res){
                    console.log('跳转到news页面成功')// success
                  },
                  fail: function() {
                  console.log('跳转到news页面失败')  // fail
                  },
                  complete: function() {
                    console.log('跳转到news页面完成') // complete
                  }
          })
          }
          
          
          //下面是我记录的日志 
          
          跳转到news页面失败
          
          
          
          
          
          
          
黄舟黄舟2804 days ago620

reply all(4)I'll reply

  • 阿神

    阿神2017-04-18 10:57:20

    1. Make sure the ../index/index page is in app.json?

    2. Is ../index/index a tabBar page? If it is a tabBar page, you cannot use wx.navigateTo, but use wx.switchTab

    The WeChat applet API is as follows:
    wx.navigateTo(OBJECT)
    Keep the current page, jump to a page in the application, and use wx.navigateBack to return to the original page.

    wx.switchTab(OBJECT)
    Jump to the tabBar page and close all other non-tabBar pages

    Tip: wx.navigateTo and wx.redirectTo do not allow jumping to the tabbar page. You can only use wx.switchTab to jump to the tabbar page

    https://mp.weixin.qq.com/debu...

    reply
    0
  • PHPz

    PHPz2017-04-18 10:57:20

    No more logs?
    If the path is not written incorrectly, try annotating the three functions success, fail, and complete and see if there are any other log outputs.
    If there is an error in the program, the console panel of the mini program will output a very detailed error message. You can just follow the error message above and correct it.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 10:57:20

    Have you registered your new page?

    reply
    0
  • 迷茫

    迷茫2017-04-18 10:57:20

    The jump path cannot be the tabBar path, otherwise it will fail

    reply
    0
  • Cancelreply