【发布时间】:2021-03-20 05:13:29
【问题描述】:
我正在从事一个涉及化学数据的高中项目。我需要从此 URL 获得响应并在另一个函数中引用它。当我尝试在挂载的函数中使用 descriptionURL 时,我收到一条错误消息,指出它未定义。任何不涉及第三方添加的帮助将不胜感激。
注意:properties.CID 来自挂载函数的请求。
computed: {
description() {
var descriptionURL = "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/" + this.properties.CID + "/description/json"
//eslint-disable-next-line no-console
console.log(descriptionURL);
axios
.get(this.descriptionURL)
//eslint-disable-next-line no-console
.then(response => {this.descriptionText = response.data})
//eslint-disable-next-line no-console
.catch(function (error) {
//eslint-disable-next-line no-console
console.log(error);
})
return descriptionURL
}
},
}
【问题讨论】:
-
能否提供一个demo
this.properties.CID值
标签: javascript vue.js axios