vue-cli 3版本没有static文件夹,本地文件应放在哪儿,如何引用
2.x版本目录:3.0版本:原来放在static下的文件,现在应该放在public文件夹下2.x 写法:methods: {fetchData () {let _this = thisthis.$http.get('/static/data/article.json').then(res => {_this.htmlTe...
·
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写法:
fetchData () {
// this.htmlText = article[this.$route.query.id].content
let _this = this;
this.$http.get('/data/article.json').then(res => {
_this.htmlText = res.data
}).catch(err => {
console.log('222222:', err)
})
}
如果json文件里有图片路径里不用加 public
<img src=\"../../public/img/details06_3.png\" alt=\"\">
改为:
<img src=\"../../img/details06_3.png\" alt=\"\">
cli3.0 项目结构 及相应作用
更多推荐
已为社区贡献3条内容
所有评论(0)