jweixin.scanQRCode({
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果
scanType: ["qrCode"], // 指定扫二维码
success: (res) => {
alert("222222");
this.isLoading = true; // 显示遮罩
// 扫码返回结果
setTimeout(() => {
this.isLoading = false; // 关闭遮罩
alert(JSON.stringify(res)); // 执行扫码结果操作
}, 2000); // 延迟加载,防止界面没有渲染
},
error: (res) => {
alert("扫码失败,请稍后再试!" + res);
this.isLoading = false; // 关闭遮罩
}
});
内置对象wx的接口们,一般都没有error回调, 失败的话是fail,把error改成fail
也可以写成 complete
详见官方文档https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#7