我知道也有类似的问题,但是我已经尝试了解决方案,但似乎没有任何作用
我的代码接受用户输入,基于该输入发出axios获取请求,并旨在将数据分配给数组staff []
export default {
data(){
return{
staffs: [],
userInput:'',
errors: '',
}
},
created:function(){
bus.$on('search-data',inputData =>{
axios.get('http://localhost:4000/stafftest?username='+inputData)
.then(response => {
console.log(JSON.stringify(response.data))
this.staffs = response.data.data
})
.catch(error =>{
console.log(error)
})
})
},
}
与其他所有人所问的问题类似,axios请求已成功发出,但不会将数据分配给数组
这是我尝试过的东西组合:
试图将其更改为function(response)等并具有var self = this,但似乎没有任何作用
我什至还设置了另一个测试页面,该页面查询pokemon API,数据分配顺利进行,这让我感到困惑,为什么在这种情况下,在该特定页面上它不起作用
感谢所有想法以解决此问题
谢谢