今天产品发现小程序上的自带分享好友的位置是灰色的,无法点击。
如图:
这个好像在每个页面需要加上 onShareAppMessage 这个函数就能开启。
mixin-share.js
export default {
data() {
return {
//这个share可以在每个页面的data中设置相应的转发内容
share:{
title:'标题',
path:'/pages/menu/home',
}
}
},
onShareAppMessage(res) {
return {
title: this.share.title,
path: this.share.path,
// imageUrl: this.share.imageUrl,
// desc: this.share.desc,
// content: this.share.content,
success(res) {
uni.showToast({
title: '分享成功'
})
},
fail(res) {
uni.showToast({
title: '分享失败',
icon: 'none'
})
}
}
}
}
uniapp中的main.js
import share from'@/common/utils/mixin-share.js';
Vue.mixin(share)
end
到这就可以了
一开始我也是在其他道友的csdn上看到的
来源链接