微信小程序(3)--頁面跳轉和提示框


微信小程序頁面跳轉方法:

1.<navigator url="../test/test"><button>點我可以切換可以返回</button></navigator>
2.<button bindtap="chageToTest">切換頁面可以返回</button>
 chageToTest:function(){
   wx.navigateTo({
     url: '../time/time',
   })
 },
3.<button bindtap="chageToTest2">切換頁面不能返回</button>
 chageToTest2:function(){
    wx.redirectTo({
      url: '../test/test',
    })
  } , 
4.<button bindtap="chageToTest3">切換底部tabbar頁面</button>
//可以跳轉tabbar欄的頁面
  chageToTest3: function () {
    wx.switchTab ({
      url: '../read/read',
    })
  }, 

微信小程序提示框:

<button bindtap="tip">提示框</button>
//提示框
  tip:function(){
    //成功
     wx.showToast({
       title: '成功',
       icon: 'success',
       duration: 2000
     })
   //加載中
     wx.showToast({
       title: '加載中',
       icon: 'loading',
       duration: 10000
     })
     setTimeout(function () {
       wx.hideToast()
     }, 2000)

    wx.showModal({
       title: '提示',
       content: '這是一個模態彈窗',
       success: function (res) {
         if (res.confirm) {
          console.log('用戶點擊確定')
        }
       }
     })
    wx.showActionSheet({
      itemList: ['A', 'B', 'C'],
      success: function (res) {
        if (!res.cancel) {
          console.log(res.tapIndex)
        }
      }
    })
  },

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM