码迷,mamicode.com
首页 > 移动开发 > 详细

vue组件+axios访问本地json

时间:2018-08-19 23:26:08      阅读:629      评论:0      收藏:0      [点我收藏+]

标签:col   fun   ajax   sage   ons   car   json   本地   weight   

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文件夹下

vue组件+axios访问本地json

标签:col   fun   ajax   sage   ons   car   json   本地   weight   

原文地址:https://www.cnblogs.com/wangpeili/p/9503093.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!