注意:本地json文件必须放在static目录下面,读取或交互数据前,请先安装vue-resource。点击前往 -->(vue-resource中文文档)
一、Vue读取本地JSON数据
created() { this.$http.get("/static/data.json").then( response => { this.data = response.data; }, response => { console.log(response); } ); },
二、Vue与后台数据交互
this.$http.get("url").then( response => { this.data = response.data; }, response => { console.log("获取失败!"); } );