当前需要使用的组件:

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 }
vue 引入本地json的方法

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

 

后台服务器请求json方式:

vue 引入本地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   });
vue 引入本地json的方法

 

 


当前需要使用的组件:

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 }
vue 引入本地json的方法

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

 

后台服务器请求json方式:

vue 引入本地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   });
vue 引入本地json的方法

 

相关文章: