- 准备一个按钮
<button class="share_button" id="shareBtn" open-type="share" type="primary">分享</button>
- 在与methods方法同级的下面写上onShareAppMessage方法
// 转发
onShareAppMessage: function (res) {
if (res.from === 'button') {
// 来自页面内转发按钮
console.log(res.target)
}
return {
title: '我的标题', // 分享出去的标题
path: "/pages/home/main?" // 分享之后再点进去的路径,可以带参数
success: function (res) {
// 转发成功
},
fail: function (res) {
// 转发失败
}
}
},
onShow() {
},
computed: {
},
mounted() {
},
components: {
},
methods: {
},