微信小程序新页面跳转

在json配置路径,会自动生成对应的css\js\json(例如:test.wxss\test.js\test.json)

页面跳转两种方法 一种通过js,一种通过页面

第一种:在要点击跳转的标签上加事件,3步,
如:1、要在点击文字上跳转
<view bindtap="toast">
    <text>点我跳转</text>
</view>
2、 bindtap="toast" 然后在js文件里写toast事件
////页面跳转 url要跳转页面的路径
toast:function(){
    wx.navigateTo({
        url: '../logs/test'
    })
}
3、在app.json里配置
"pages":[
    "pages/logs/test"
],

第二种:

<navigator url="../logs/test">跳转到新页面</navigator>
或者在上面加上这句 open-type="redirect" 在当前页打开
或者 open-type="switchTab"  切换到首页Tab

navigator的open-type属性 可选值 'navigate'、'redirect'、'switchTab',对应于wx.navigateTo、wx.redirectTo、wx.switchTab的功能

open-type="navigate"等价于API的 wx.navigateTo 而wx.navigateTo的url是需要跳转的应用内非 tabBar 的页面的路径

open-type="redirect"等价于API的 wx.redirectTo 而wx.redirectTo的url是需要跳转的应用内非 tabBar 的页面的路径

open-type="switchTab"等价于API的 wx.switchTab而wx.switchTab的url是需要跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面

最后一个switchTab事件触发以后 把前面的页面都关闭了

猜你喜欢

转载自blog.csdn.net/qq_39109182/article/details/80944350