代码:
打开APP查看
export default {
data() {
return {
isWeiXin:true,
};
},
mounted() {
console.log('检查微信 SDK 是否加载',window.wx);
console.log('检查按钮 DOM ',document.getElementById('launch-btn'));
console.log('当前URL:', window.location.href.split('#')[0]);
if(this.isWeiXin){
const btn = document.getElementById('launch-btn');
this.handleSdk()
}
},
methods: {
handleSdk(){
var urls = window.location.href.split('#')[0];
this.$axios.post('/oss/wechatAuth/h5JumpMini', {
url: urls
}).then((res) => {
console.log(res)
if (res.data.rel) {
wx.config({
debug: true,
appId: res.data.data.appId,
timestamp: res.data.data.timestamp,
nonceStr: res.data.data.nonceStr,
signature: res.data.data.signature,
jsApiList: ["wx-open-launch-app","onMenuShareAppMessage", "onMenuShareTimeline"],
openTagList: ["wx-open-launch-app"],
})
wx.checkJsApi({
jsApiList: ['wx-open-launch-app'],
success: function (res) {
console.log('可用')
},
fail: (err) => {
console.log(err, '不可用')
}
})
wx.error(function (res) {
console.log(res, 'error');
});
}
}
})
},
onListenLaunchError(e) {
},
handlelaunch(){
console.log('链接跳转');
},
},
};
你好,Debug一下,控制台打印相关参数和config参数截图