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

 
posted @ 2018-08-19 22:45  芋头猪爸爸  阅读(2526)  评论(0编辑  收藏  举报
我的主页