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   });
復制代碼

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM