在我有Admin.vue的组件中,我使用
调用图像<img :src="imageuser">
这里的组件Admin.vue我调用脚本导出默认值
export default{
data(){
return{
lists:{},
imageuser:"",
}
},
mounted(){
axios.post('admin/getDataAdmin',this.$data)
.then((response)=> this.lists = response.data)
.then((response)=>this.imageuser="source/admin/assets/img/"+response.data.image)
.catch((error)=> this.errors = error.response.data.errors);
},
我可以将数据库中的数据传输到数组lists
,但是在imageuser中我得到imageuser:""
。当我console.log(response.data.image)
时,我收到错误Cannot read property 'data' of undefined
答案 0 :(得分:1)
您的第一个处理程序已经返回if ((x & y) != 0) {
printf(" ");
}
else {
printf("* ");
}
:
data
执行:
axios.post('admin/getDataAdmin',this.$data)
.then((response)=> this.lists = response.data) // this returns `response.data`
.then((response)=> // so, at this point, the argument is `response.data`
this.imageuser="source/admin/assets/img/"+response.data.image
)
但是,根据您的错误,axios.post('admin/getDataAdmin',this.$data)
.then((response)=> this.lists = response.data)
.then((data)=>this.imageuser="source/admin/assets/img/"+data.image)
// ^^^^ --- changed changed ---^^^^
正在response.data
。