欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

微信小程序设置 全局共享

最编程 2024-03-20 16:34:14
...

代码已上传至github github代码地址:https://github.com/Miofly/mio.git

App.vue

onShow () {
    // #ifdef MP-WEIXIN
    this.share()
    // #endif
    console.log('onShow:应用页面显示')
},
method: {
    share: function () { // 全局分享
        wx.onAppRoute(res => {
            const pages = getCurrentPages()
            const view = pages[pages.length - 1]
            wx.showShareMenu({
                withShareTicket: true
            })
            view.onShareAppMessage = function () {
                return {
                    title: '这是个大宝贝!',
                    path: view.route
                }
            }
        })
    }
}

推荐阅读