<button open-type="share" plain class="item share" @click.stop="shareFn(item)"><text>分享</text>
</button>
import {onShareAppMessage} from '@dcloudio/uni-app'let shareObj = ref({})// 將點擊后的分享設置信息 關鍵就是這個promise resolve的結果就是分享的數據信息onShareAppMessage(() => {const promise = new Promise(resolve => {setTimeout(() => {resolve({title: '分享信息-'+shareObj.value.desc,desc: shareObj.value.desc,path: shareObj.value.path})}, 100)})return {promise}})
// 點擊 設置分享信息 let shareFn = (item) => {console.log(item, 'item');shareObj.value.desc = item.lifeshareContentshareObj.value.path = '/pages/comment-detail/comment-detail?lifeshareId=' + item.lifeshareId}
這個是官網的信息
https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/miniapp/component/onShareAppMessage.html
結果