微信小程序—页面跳转

问题:

  实现页面跳转:index页面通过按钮跳转到next页面

方法:

  1、页面index.wxml增加一个按钮

1 // index.wxml
2 <button bindtap="jump">跳转</button>

  2、在index.js中添加跳转逻辑

1 // 调转函数
2 jump: function () {
3     wx.navigateTo({
4       url: "../next/next"
5     })
6 },

  3、重点:

    button 表单组件:官方链接:https://developers.weixin.qq.com/miniprogram/dev/component/button.html

      bindtap :在组件中绑定一个事件处理函数

    wx.navigateTo(Object object) :官方链接:https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateTo.html

      保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 wx.navigateBack 可以返回到原页面。小程序中页面栈最多十层