// 小程序右上角分享-全局分享
module.exports = {
onShow() {
let pages = getCurrentPages();
if (pages.length >= 1) {
this.$x.pageRouter = (pages[pages.length - 1]).route
if (this.$x.pageRouter) {
this.$x.mpShare = {
title: '设备故障一键报修', // 分享标题
path: '', // 默认为当前页面路径
imageUrl: '' // 默认为当前页面的截图
}
}
return;
}
},
// 分享到好友
onShareAppMessage(el) {
return this.$x.mpShare
},
// // 分享到朋友圈
onShareTimeline() {
return this.$x.mpShare
}
}
js
main.js引入
// 全局分享
const $x = {};
Vue.prototype.$x = $x;
let share = require('./js/share/share.js');
Vue.mixin(share);