技术:vue1x,vuex1x
已解决,前台这么写没有问题。
图片描述
<template>
<h3 style="display:none"></h3>
</template>
<script type="text/javascript">
import store from './../../vuex/store'
import {getShare,getHotelId} from './../../vuex/getter'
import wx from 'weixin-js-sdk'
export default {
data () {
return {
}
},
store,
ready(){
this.wxinit(this.getShare)
},
methods:{
wxinit(shareobj) {
wx.config({
debug: true,
appId: shareobj.appId,
timestamp: shareobj.timestamp,
nonceStr: shareobj.nonceStr,
signature: shareobj.signature,
jsApiList: [
'onMenuShareTimeline', //
'onMenuShareAppMessage', //
'onMenuShareQQ',
'onMenuShareWeibo',
'onMenuShareQZone'
]
});
wx.ready(function() {
var shareObj = { //
title: shareobj.share_title,
desc: shareobj.share_content,
link: shareobj.url,
imgUrl: shareobj.share_img,
};
wx.onMenuShareTimeline({
title: shareObj.title, //
desc: shareObj.desc, // 描述
link: shareObj.link, //
imgUrl: shareObj.imgUrl, //
success: function(res) {},
cancel: function(res) {}
});
//分享到好友
wx.onMenuShareAppMessage({
title: shareObj.title, // 标题
desc: shareObj.desc, // 描述
link: shareObj.link, // 链接
imgUrl: shareObj.imgUrl, // 图片
success: function(res) {},
cancel: function(res) {},
}); //
wx.onMenuShareQQ({
title: shareObj.title,
desc: shareObj.desc,
link: shareObj.link,
imgUrl: shareObj.imgUrl,
success: function(res) {},
cancel: function(res) {}
});
//
wx.onMenuShareWeibo({
title: shareObj.title,
desc: shareObj.desc,
link: shareObj.link,
imgUrl: shareObj.imgUrl,
success: function(res) {},
cancel: function(res) {}
});
//
wx.onMenuShareQZone({
title: shareObj.title,
desc: shareObj.desc,
link: shareObj.link,
imgUrl: shareObj.imgUrl,
success: function(res) {},
cancel: function(res) {}
});
});
wx.error(function(res) {
//
console.log(res)
});
}
},
vuex:{
getters:{getShare},
}
}
</script>
config fail
这个就是配置的错误,先检查一下配置是否设置正确timestamp nonceStr signature