vue组件+axios访问本地json

import axios from 'axios'
export default {
name: "AjaxText",
data: function () {
return {
message: {}
}
},
mounted() {
this.cartView();
},
methods:{
cartView() {
let vm=this;
axios.get("/static/sites.json", {}).then(function (response) {
vm.message = response.data;
})
}
}
}


webstrom创建的vue项目,本地json要放在static文件夹下

猜你喜欢

转载自www.cnblogs.com/wangpeili/p/9503093.html