Vue.js 代码错误解决:Missing Semicolon and Function Definition
您提供的代码中存在两个问题:
- 缺少分号:在
onLoad函数的结尾缺少一个分号。
onLoad(option) {
this.info.storeId = option.storeId;
this.source = this.IsWeixinOrAlipay();
alert(this.source); // 输出用户来源:WeiXIN 或 Alipay 或 false
}
- 函数定义错误:
getCode函数没有正确定义。
getCode() {
let appid = 'XXXXXXXX'; //个人开发者appid
let redirect = encodeURIComponent('https://XXXXXXX.com/pindex.html#/visitor/appointment/appointment');
let wx_code = this.getUrlParam('code'); // 截取url中的code
if (!wx_code) {
window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect}&response_type=code&scope=snsapi_base&state=#wechat_redirect`;
} else {
this.getOpenId(wx_code); //把code传给后台获取用户openid
}
}
此外,请确保 getUrlParam 函数的结尾也添加了右括号。
通过修复这些问题,您的代码将能够正常运行。
原文地址: https://www.cveoy.top/t/topic/caC0 著作权归作者所有。请勿转载和采集!