Taro.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline'],
success(res) {
console.log(res)
},
fail(e) {
console.log(e)
}
})
Taro.useShareAppMessage(res => {
if (res.from === 'button') {
// 来自页面内转发按钮
console.log(res.target)
}
return {
title: '顺医控关爱到家',
imageUrl: 'https://cdn2.jianshu.io/assets/default_avatar/2-9636b13945b9ccf345bc98d0d81074eb.jpg',
path: '/pages/home/index?from=mini_ShareApp',
}
})
Taro.useShareTimeline(() => {
return {
title: '顺医控关爱到家', //字符串 自定义标题
query: '/pages/home/index?from=mini_Timeline', //页面携带参数
imageUrl: 'https://cdn2.jianshu.io/assets/default_avatar/2-9636b13945b9ccf345bc98d0d81074eb.jpg' //图片地址
}
})
// index.config.ts
export default {
// 当 `onShareAppMessage` 没有触发时,可以尝试配置此选项
enableShareAppMessage: true
}