小程序右上角原生菜单自带的分享按钮,默认不可用

1.创建一个mixin share.js
export default {
created() {
//#ifdef MP-WEIXIN
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
});
//#endif
},
}
export default {
created() {
//#ifdef MP-WEIXIN
wx.showShareMenu({
withShareTicket: true,
menus: ["shareAppMessage", "shareTimeline"],
});
//#endif
},
onShareAppMessage(res) {
// 发送给朋友
return {
// title: "your title",
// imageUrl: "your image",
};
},
onShareTimeline(res) {
// 分享到朋友圈
return {
// title: "your title",
// imageUrl: "your image",
};
},
};
2.全局使用,在 main.js 里面 添加全局的 mixin
import share from './common/share.js'
Vue.mixin(share)
3.单个页面使用,单个页面引入 share.js
4.成果展示
