0
我是Vue.js中的新成员。我想从ajax数据更新数据。Vue.js更新数据属性变量中的ajax数据
<template>
<span class="label_cont">This is to certify that</span> {{ name }}
</template>
我想要{{ name }}
变量从ajax数据。
这里是我的js代码
export default{
created(){
const url = 'app/result.php';
this.$http.get(url).then(response => {
this.resp = response.body;
});
},
data(){
return {
resp:[],
name: resp.name,
}
}
}
在我的AJAX name
属性是this.resp.name
更新:
这里是我的Ajax响应数据格式
{
"name": "X",
"class": "Y",
"roll": "Z"
}
你有什么数据response.body?向我们显示数据格式 –
我已经更新了数据格式 – alien