我已經將一個計算屬性綁定到Vue.js中圖像標記的src
。該代碼似乎是正確的,但並不一致,這對我來說是莫名其妙的。此外,切換到頁面並返回到主要圖書頁面始終正確顯示圖像。Vue.js組件圖像空白
任何有關可能導致此問題的信息都會很棒!
甲託管該應用的版本是可用這裏:https://books.surge.sh/
The relevant code for the book-item component.
的碼生成的書分量和圖像src
如下:
<template>
<article class="book-item">
<img :src="imgSrc" class="image">
<div class="meta">
<div class="name">{{ book.title }}</div>*
<div class="author">{{ book.author }}</div>
</div>
<div class="description">
<p v-html="book.description"></p>
</div>
</article>
</template>
<script>
export default {
props: ['book'],
computed: {
imgSrc() {
return `/static/img/${this.book.image}`;
}
}
};
</script>
部分在初始加載時顯示書籍封面:
看起來像你的CSS問題,因爲如果你打開鉻devtools,並檢查元素,你總是可以看到src標籤,並正確鏈接。當我簡單地將你的'img'設置爲'display:block'時,它已經觸發並渲染它。 –
*更新:只要內容以任何方式重新繪製,任何元素中的任何佈局更改都會導致它呈現。這可能是一個好的開始。 –