博客 / 詳情

返回

微信小程序 設置 全局分享

onAppRoute這個是小程序的一個隱藏的方法。自己可以打印看看
在app.js中

  onLaunch () {
    this.mpShare()
  },
  mpShare () {
    wx.onAppRoute(res => {
      const pages = getCurrentPages()
      const view = pages[pages.length - 1]
      if (view) {
        const data = view.data
        if (!data.isMpShare) {
          data.isMpShare = true
          view.onShareAppMessage = () => {
            return {
              title: '小程序',
              path: '/pages/home/home'
            }
          }
        }
      }
    })
  },
user avatar
0 位用戶收藏了這個故事!

發佈 評論

Some HTML is okay.