项目使用mock数据,报错
来源:7-10 Vue项目首页 - 首页父子组组件间传值
 
			向着仙女出发
2019-07-11
home.vue
import axios from 'axios'
mounted (){
      this.getHomeInfo()
    },
methods:{
      getHomeInfo(){
        axios.get('/api/index.json')
          .then(this.getHomeInfoSucc)
      },
      getHomeInfoSucc(res){
        res = res.data;
        if(res.ret && res.data){
          const data = res.data;
          this.city =data.city;
          this.swiperList =data.swiperList;
          this.iconList =data.iconList;
          this.recommendList = data.recommendList;
          this.weekendList = data.weekendList;
        }
      }
    }
index.js
proxyTable: {
      '/api':{
        target:'http://localhost:8080',
        pathRewrite:{
          //路径替换 如果请求地址以api开头则替换路径
          '^/api':'/static/mock'
        }
      }
    },
index.json文件,是直接下拉下来的
报错
写回答
	1回答
- 
				  Joyceshen 2019-07-11 改了配置文件要重启项目,还有可能的地方就是json文件有没有放错位置 00
相似问题
