首页 > 其他 > 详细

vue-cli 3版本没有static文件夹,本地文件应放在哪儿,如何引用

时间:2019-11-28 11:06:43      阅读:1020      评论:0      收藏:0      [点我收藏+]

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 项目结构 及相应作用

技术分享图片

 

vue-cli 3版本没有static文件夹,本地文件应放在哪儿,如何引用

原文:https://www.cnblogs.com/xiaozhu-zhu/p/11946845.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!