【发布时间】:2017-12-16 10:44:56
【问题描述】:
使用 vue 2.1.10 vue-resource 1.3.4 获取数据:
const app = new Vue({
el: '#UserController',
data:{
users : [],
},
methods:{
fetchUser: function(){
this.$http.get('http://localhost:8000/api/api/users', function(data){
this.$set('users',data)
})
}
},
mounted(){
this.fetchUser()
}
});
但最终
用户没有价值。
【问题讨论】:
-
Vue.set的参数是(target, key, value)。见vuejs.org/v2/api/#Vue-set。 -
试试
this.users = data -
我试过 this.users = data ,,, 不起作用! :| :(
-
您的 .../api/api/.. 网址似乎可疑
-
网址正常工作
标签: javascript vue.js vuejs2 vue-resource