案例
分享的时候弹出对应的标题和默认第一张图片
代码
<view v-for="(item,index) in list" :key="index"><button open-type="share" :id="index" @click.stop="()=>{}"><image src="/static/images/circle/share.png" mode="aspectFill"></image></button>
</view>
onShareAppMessage((res) => {console.log(res);if (res.from === 'button') { // 来自页面内分享按钮return {title: list.value[res.target.id].title,path: '/pages/circle/circle',imageUrl: i.image(list.value[res.target.id].images[0]),}} else {return {title: common.config.title,path: '/pages/index/index',imageUrl: i.image(common.config.image),}}
})
重点是open-type="share" :id="index"
id绑定索引用以来识别