0
我试图获取使用Vue公司+ Vuex + Vue公司resource.On按钮服务器数据单击我想打HTTP请求并显示在列表格式。我试图像that.Here是我的代码如何从vue js中的服务器获取数据?
https://plnkr.co/edit/EAaEekLtoiGPvxkmAtrt?p=preview
// Code goes here
var store = new Vuex.Store({
state: {
Item: []
},
mutations: {
getItems: function (state) {
}
},
actions: {
fetchData:function (context) {
this.$http.get('/data.json', function(v1users)
{
// this.$set('v1_user',v1users);
});
}
}
})
var httprequest = Vue.extend({
"template": '#http_template',
data: function() {
return {
items: store.state.Item
}
},
methods: {
fetchData: function() {
store.dispatch('fetchData')
},
}
})
Vue.component('httprequest', httprequest);
var app = new Vue({
el: '#App',
data: {},
})
; 任何udpdate?
请你分享plunker – naveen
我怎么会做呢? – naveen
无需plunker ..只要请'Vue.http.get'在你的代码替换'这一点。$ http.get'。这是你需要做的唯一改变。 – mariodev