vue项目
要做个微信分享的功能
网上各种搜,写出代码如下,但是点击并没任何反应,求大神指导
<template>
<button @click="share">分享</button>
</template>
<script>
import wx from 'weixin-js-sdk'
activated () {
this.initWxConfig()
},
methods: {
share () {
console.log('share')
var shareData = {
// imgUrl: 'http://yzdw.dream-world.com.cn/ftp/static/u/cms/www/201810/111529310qzz.jpg',
imgUrl: 'http://yzdw.dream-world.com.cn/ftp/static/u/cms/www/images/f6081d232c67e61700a3d0b0a5a7c82.jpg',
link: location.href.split('#')[0],
desc: '分享描述',
title: '分享标题',
type: 'link',
success: function(res){
console.log(res, '分享好了')
this.$toast('success')
}
}
wx.ready(res => {
console.log(res, '---wx ready---')
console.log(wx.onMenuShareAppMessage, 'onMenusharemssage')
console.log(shareData, 'share data')
// wx.updateAppMessageShareData(shareData)
wx.onMenuShareAppMessage(shareData)
})
wx.error(function(err){
console.log(err, '失败信息')
})
},
initWxConfig() {
var ua = navigator.userAgent.toLowerCase()
var isWeixin = ua.indexOf('micromessenger') !== -1
if (isWeixin) {
// 这里是获取签名 appid等数据
axios.get(apis.wechatShare, {
params: {
url: location.href.split('#')[0]
}
}).then(res => {
const {body, code} = res.data
if (code === '200') {
wx.config({
debug: false,
appId: body.appId,
nonceStr: body.noncestr,
signature: body.signature,
timestamp: body.timestamp,
jsApiList: [
// 'updateAppMessageShareData'
'onMenuShareAppMessage'
]
})
}
})
} else {
this.$toast('请在微信中打开该网站, 否则无法正常使用')
}
}
}
</script>
wx.config end 显示errMsg: "config:ok"就是配置正确了吗
但为什么调用share,并没有出现选择好友的界面,请大神指导
请问是怎么回事儿啊