宠物网站页面设计创意国外,网页制作大宝库,免费适合个人主页,海外电商平台有哪些使用Promise #xff0c;当 layer.msg(查询成功) 这个方法执行结束后 #xff0c;下面代码才会执行 let thas this
async function showMessage() {await new Promise(resolve layer.msg(查询成功, resolve));// 这里的代码将在 layer.msg 执行结束后执行thas.isGuaran…使用Promise 当 layer.msg(查询成功) 这个方法执行结束后 下面代码才会执行 let thas this
async function showMessage() {await new Promise(resolve layer.msg(查询成功, resolve));// 这里的代码将在 layer.msg 执行结束后执行thas.isGuarantee true;thas.InsurancePolicyInfo res.data;thas.ifTimeClose();
}
showMessage();
注意事项Promise内如果使用 this , this无法访问到Vue实例 解决方法 1.你需要在外部定义全局变量 值是this, 在promise内使用这个变量2.直接调用Vue组件实例 描述箭头函数不会改变 this 的指向它会捕获外部上下文的 this。因此在箭头函数内部this 会指向 Vue 组件的实例
async showMessage() {await new Promise(resolve layer.msg(查询成功, resolve));this.isGuarantee true;this.InsurancePolicyInfo res.data;this.ifTimeClose();
}// 在 Vue 组件中调用 showMessage
this.showMessage();