作者:燕歆波
导读:虽然官方提供了文档,但是还是走了一个小小的坑
首先定义分享按钮,注意open-type属性的值是share
<button class='share' plain='true' open-type="share">分享</button>
然后在js文件中复写onShareAppMessage方法:
onShareAppMessage: function() {
return {
title: '若只如初见',
path:"",
imageUrl: ''
}
}
需要注意的是,path是当前页面路径(如果不是分享本页面可以忽略不写),imageUrl才是你要分享的图片,官方文档好像并没有指出这一点,或者我大意没看到。。。