javascript - 小程序跳转失败?
黄舟
黄舟 2017-04-18 10:55:20
0
4
568
     绑定了一个点击事件 
      <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页面失败
          
          
          
          
          
          
          
黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(4)
阿神

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...

PHPzhong

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.

Ty80

Have you registered your new page?

迷茫

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!