test.json和html在同一路径下,为甚不能设置初始数据?
click{{gridData}}{{apiUrl}}
var demo = new Vue({
el: '#app',
data: {
gridData: "",
apiUrl: 'test.json'
},
created: function() {
this.getCustomers()
},
methods: {
getCustomers: function() {
this.$http.get(this.apiUrl)
.then((response) => {
console.log(response.success)
this.$set('gridData', response.success)
})
.catch(function(response) {
console.log(response)
})
}
}
})
test.json
{
"success": true
}