1、当前页面使用转发按钮
官网的介绍
<button type="default" open-type="share" @ShareAppMessage="onShareAppMessage()" class="share-btn">转发</button>
data(){
return{
share:{
title:'活动分享',
path:'/pageB/activityDetail/activityDetail/?id='+this.id,
imageUrl:this.baseURL+ "?temp=" + Date.parse(new Date()),
desc:'',
content:''
},
}
onShareAppMessage(res) {
if (res.from === 'button') {
console.log(res.target)
}
return {
title:this.share.title,
path:this.share.path,
imageUrl:this.share.imageUrl,
desc:this.share.desc,
content:this.share.content,
}
},
methods: {
onShareAppMessage(e){
console.log(e,'转发了');
},
}
2、如果是全局配置转发功能,可以配置全局的
1、创建一个share.js文件,引入到main.js文件,全局混入
JS文件
export default{
data(){
return {
share:{
title:'工业安全小程序分享',
path:'/pages/tabbar/index/index',
imageUrl:'',
desc:'',
content:''
},
$imgUrl:'https://dev-file.ancai88.com:8071'
}
},
onShareAppMessage(res) {
if (res.from === 'button') {
console.log(res.target)
}
return {
title:this.share.title,
path:this.share.path,
imageUrl:this.share.imageUrl,
desc:this.share.desc,
content:this.share.content,
}
}
}
main.js
import share from '@/utils/share.js'
Vue.mixin(share)
|