【发布时间】:2019-02-15 08:51:42
【问题描述】:
我正在使用 vue 在扩展程序的登录页面上设置错误消息,并且在 importCreds() 函数中出现错误。
data(){
return {
url:'',
apikey:'',
error:'',
}
},
methods:{
accountSummaryButton(){
if (localStorage.getItem("accounts") == null)
this.error = 'There are no available accounts.';
}
else
// STUFF
},
saveLogin(event){
let app = this;
if (!app.getAccountData(app.url,app.apikey,this.method))
this.error = 'An error has occurred, please check Url and API Key.';
else {
//STUFF
}
},
importCreds(){
let app = this;
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(
tabs[0].id,
{action: "import_creds"},
function(response) {
if (response){
app.url = response.affiliateurl
app.apikey = response.apikey
} else
this.error = 'Go to your affiliate site.';
}
);
});
},
},
我是否缺少在该函数中访问 error 的简单方法?
【问题讨论】:
标签: javascript vue.js undefined typeerror