vue动态加载图片

写vue轮播,需要加载图片,直接把图片写进勒data,发现加载出来是字符串,故而查询资料,解决此问题
把图片放在static中,可以正常加载,如果图片再assets中就只能引入,至于为什么,,,,我有空再去查吧
html:



vue动态加载图片
文章图片



vue动态加载图片
文章图片




js:
data(){
return{
items:[{src:"../assets/logo.png"},{src:"../assets/logo.png" }],
swiperOption:{
pagination:'.swiper-pagination',
slidesPerView:'auto',
centeredSlides:true,
paginationClickable:true,
onSlideChangeEnd:swiper=>{
// 这个位置放swiper的回调方法
this.page = swiper.realIndex+1;
this.index = swiper.realIndex;
},
},
swiperSlides:[1,2,3,4,5]
}
},

【vue动态加载图片】图片并没有出来,效果是
vue动态加载图片
文章图片


所以这是不对的,那么怎么解决这个问题呢:
vue动态加载图片
文章图片


酱汁




    推荐阅读