第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 Vue.JS 中使用計算屬性 v-bind 圖像 src

在 Vue.JS 中使用計算屬性 v-bind 圖像 src

陪伴而非守候 2023-08-24 15:45:06
我有一個包含一些對象的 JSON 文件,這些對象是使用計算屬性渲染出來的JSON:{     "id": 6,     "formula": "2+2",     "description": "Just a description.",     "image": "../assets/img/id6.png",     "answers": [        { "answerId": 0, "answerInput": "Funktion", "correct": false},        { "answerId": 1, "answerInput": "Relation", "correct": true}     ]}所有數(shù)據(jù)均已正確呈現(xiàn)。腳本標(biāo)簽:computed:{  filterById(){      return this.exercises.find(exercises => exercises.id === this.exId)    }  }模板標(biāo)簽:<div class="task-description">  <h2>{{ filterById.description }}</h2>  <img :src="`${filterById.image}`" alt=""></div>但由于某種原因我無法渲染圖像,我確信圖像的路徑是正確的。
查看完整描述

1 回答

?
RISEBY

TA貢獻1856條經(jīng)驗 獲得超5個贊

最后我使用了以下方法:


getImgUrl(path) {

    var images = require.context('../assets/img/')

    return images('./' + path + ".png")

}

并輸出這樣的圖像


<img v-if="filterById.id == 7 || filterById.id == 6" :src="getImgUrl(filterById.image)">


查看完整回答
反對 回復(fù) 2023-08-24
  • 1 回答
  • 0 關(guān)注
  • 190 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號