圖片引入不顯示問題

圖片放在 assets目錄下 和static 目錄下
  • 固定的引入(不使用v-bind)
<img src="../assets/logo.png">
  • 把圖片放static 目錄,直接通過data引入
// template
<img v-bind:src=imgSrc>
// srcipt
export default {
  data () {
    return {
      imgSrc: '../static/launch.png'
    };
  }
};

或者不通過data,直接在html中引入

//template
<ul class="index-board-list">
        <li class="board-item" v-for="(item,index) in boardList" :class="[{'line-last':index % 2 != 0},'index-board-' + item.id]">
          <img :src="'../../static/images/'+(index+1)+'.png'">
          <p>{{index}}</p>
          <div class="board-item-right">
            <p>{{ item.title }}</p>
            <p>{{ item.description }}</p>
            <button class="buy_now">立即購買</button>
          </div>
        </li>
      </ul>
//script
export default {
  data() {
    return {
      boardList: [
        {
          title: "開放產(chǎn)品",
          description: "開放產(chǎn)品是一款開放產(chǎn)品",
          id: "car",
          toKey: "analysis",
          saleout: false,
          // src: "../../static/images/1.png"
        },
        {
          title: "品牌營銷",
          description: "品牌營銷幫助你的產(chǎn)品更好地找到定位",
          id: "earth",
          toKey: "count",
          saleout: false,
          // src: "../../static/images/2.png"
        },
        {
          title: "使命必達(dá)",
          description: "使命必達(dá)快速迭代永遠(yuǎn)保持最前端的速度",
          id: "loud",
          toKey: "forecast",
          saleout: true,
          // src: "../../static/images/3.png"
        },
        {
          title: "勇攀高峰",
          description: "幫你勇闖高峰,到達(dá)事業(yè)的頂峰",
          id: "hill",
          toKey: "publish",
          saleout: false,
          // src: "../../static/images/4.png"
        }
      ]
    }
  }
};
  • 如果放在其它目錄(如assets目錄),直接通過data引入,則需要如下引入
require('../assets/launch.png') 或者 import logo from '../assets/logo.png'

如:

// template
<img v-bind:src=imgSrc>
// srcipt
export default {
  data () {
    return {
      imgSrc: require('../assets/launch.png')
    };
  }
};
import logo from '../assets/logo.png
// template
<img v-bind:src=imgSrc>
// srcipt
export default {
  data () {
    return {
      imgSrc: logo
    };
  }
};
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,544評論 19 139
  • 第一次坐爸爸的車 睡醒了 張開睡眼朦朧的雙眼 這是哪兒 發(fā)現(xiàn)不是我熟悉的大床 不是我的小搖籃 不是我常睡的那張軟軟...
    野渡游人閱讀 241評論 0 0
  • 畫這副畫時,仿佛自己就坐在窗邊。窗外,雪將落未落。窗內(nèi),爐火嗶剝,明明又滅滅。竹爐湯沸時,有人恰好在對面落座。也不...
    淺野微山閱讀 277評論 0 4

友情鏈接更多精彩內(nèi)容