vue2中img标签的src是动态渲染的,路径是对的,就是显示不出来
解法来源于这位大佬:https://www.cnblogs.com/corgisyj/p/12025012.html。加上require() 即可。
·
解决方案:
<div class="flowerProduct" v-for="item in productList" :key="item.id">
<img :src="item.img?require(`@/assets/product/${item.img}`):''" alt="图片走丢了">
<span>{{ item.title }}</span>
<span>{{ item.productPrice }}</span>
</div>
加上require() 即可
解法来源于这位大佬:https://www.cnblogs.com/corgisyj/p/12025012.html
更多推荐
已为社区贡献4条内容
所有评论(0)