【发布时间】:2020-05-31 07:47:14
【问题描述】:
我有一个带有 axios 调用的组件。我用一个道具声明了其中两个,这些道具将 uri 提供给 axios 调用
export default {
name: "CardData",
props :['uri','suffixe' ,'label'],
data : function (){
return {
lab : this.label,
suff: this.suffixe,
data :0,
}
},
methods :{
init(){
self = this;
this.$http.get(this.$ApiUri+this.uri)
.then(function (response) {
self.loading = true;
// handle success
if (response.data){
if (response.data.nb){
console.log('we have nb :' + response.data.nb );
self.data = response.data.nb;
}
self.loading = false;
}
})
.catch(function (error) {console.log(error);});
},
},
mounted(){
this.init();
},
我有一个容器两次调用这个组件
<CardData uri="getNbNews" suffixe=" " label="News" :key="100" ></CardData>
<CardData uri="getNbSources" suffixe=" " label="Sources" :key="101"></CardData>
我可以在 console.log 上看到 response.data.nb 的结果 但只有一个在前面更新...其他包含 0 我想不通
【问题讨论】: