uniapp applet global sharing method

The uniapp applet realizes the function of forwarding to friends and sharing to Moments

Create a js file, my file path is: common/share.js

export default {
    created() {
        //#ifdef MP-WEIXIN
        wx.showShareMenu({
            withShareTicket: true,
            menus: ['shareAppMessage', 'shareTimeline']
        });
        //#endif
    },
}

For global use, add a global mixin in main.js

import share from './common/share.js'
Vue.mixin(share) 
const app = new Vue({
    ...App,share
})

Guess you like

Origin blog.csdn.net/starstarstarl/article/details/129021577