2.x版本目錄:
3.0版本:
原來放在static下的文件,現在應該放在public文件夾下
2.x 寫法:
methods: { fetchData () { let _this = this this.$http.get('/static/data/article.json').then(res => { _this.htmlText = res.data }).catch(err => { console.log('22222:', err) }) } }
3.0寫法:
1 fetchData () { 2 // this.htmlText = article[this.$route.query.id].content 3 let _this = this; 4 this.$http.get('/data/article.json').then(res => { 5 _this.htmlText = res.data 6 }).catch(err => { 7 console.log('222222:', err) 8 }) 9 }
如果json文件里有圖片路徑里不用加 public
1 <img src=\"../../public/img/details06_3.png\" alt=\"\">
改為:
1 <img src=\"../../img/details06_3.png\" alt=\"\">
cli3.0 項目結構 及相應作用