zoukankan      html  css  js  c++  java
  • vue-cli 3版本没有static文件夹,本地文件应放在哪儿,如何引用

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

  • 相关阅读:
    touchMove VS touchCancel
    svg viewbox 作用
    reactjs reactLink
    放开linux下的端口
    运算符重载函数作为类成员函数和友元函数 (转)
    MBean和MXBean 区别
    transfer-encoding
    CSRF
    vue知识拓展
    居中
  • 原文地址:https://www.cnblogs.com/xiaozhu-zhu/p/11946845.html
Copyright © 2011-2022 走看看