vue 引入本地json的方法

 


当前需要使用的组件:

复制代码
 1 import data from './test.json'
 2   export default{
 3     data(){
 4       return{
 5         userinform: ''
 6       }
 7     },
 8 mounted(){
 9   this.userinform = data
10   }
11 }
复制代码

test.json就是普通json格式就可以了!然后完美解决!

后台服务器请求json方式:

复制代码
1   this.$http.get('url').then(response => {
2     //succces callback
3 
4     var data = response.body;
5   }, response => {
6     // error callback
7     alert('连接失败!')
8   });
复制代码

 

原文地址:https://www.cnblogs.com/onesea/p/12985618.html