代码实现
<button open-type="share" @onShareAppMessage="onShareAppMessage">转发</button>
onShareAppMessage() {
return {
title: '贵州立智科技有限公司邀请您加入易流协作',
imageUrl: '/static/logo.png',
path: '/pages/login/login?companyId=123'
}
}
// 参数的获取在对应的页面操作
onLoad(option) {
console.log(option.companyId); // 打印出上个页面传递的参数
}
微信展示分析
分享后微信的样式如下:
而其中图片默认为分享页截图,大小为:245*200,且固定,最好自定义
动态携带参数问题
将传递的参数打印发现:
即@onShareAppMessage
无法传递参数,多次尝试后只能对id下手
<button class="share" open-type="share" :id="item.name + '_' +item.id"
@onShareAppMessage="onShareAppMessage">
<text>分享</text>
</button>
然后对ID进行拆分处理,加入其他属性也不会出现