vue的src的动态绑定赋值问题
html:< li v-for=“item in items”>< img :src=“item.src” alt="" />script : data(){items:[{id:1, src:require(’…/…/assets/item2.jpg’)},{id:2, s
·
记录
html: < li v-for=“item in items”>< img :src=“item.src” alt="" />
script : data() {
items:
[
{id:1, src:require(’…/…/assets/item2.jpg’)},
{id:2, src:require(’…/…/assets/item2.jpg’)},
{id:3, src:require(’…/…/assets/item2.jpg’)},
{id:4, src:require(’…/…/assets/item2.jpg’)},
{id:5, src:require(’…/…/assets/item2.jpg’)}
],
起初: src:’…/…/assets/item2.jpg’ 无效,请求不到;
改成 src:require(’…/…/assets/item2.jpg’
解决参考:
https://blog.csdn.net/Milan_KunderLa/article/details/80319548
https://blog.csdn.net/weishidong/article/details/78214882
更多推荐
已为社区贡献1条内容
所有评论(0)