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 }
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   });
当前需要使用的组件:
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   });
以上是 vue 引入本地json的方法 的全部内容, 来源链接: utcz.com/z/380453.html






