Vue使用element-ui 幻灯片,图片无法显示的解决方法
作者:互联网
data中的路径只会被当做普通的字符串,因此无法获取图片
data () {
return {
carousels: [
“…/assets/img/carousel_1.png”,
“…/assets/img/carousel_2.png”,
“…/assets/img/carousel_3.png”,
“…/assets/img/carousel_4.png”
]
}
}
加上 require()
data () {
return {
carousels: [
require("…/assets/img/carousel_1.png"),
require("…/assets/img/carousel_2.png"),
require("…/assets/img/carousel_3.png"),
require("…/assets/img/carousel_4.png")
]
}
}
原文链接:https://blog.csdn.net/qq_45668489/article/details/104963236
标签:Vue,assets,img,require,element,ui,carousel,data,png 来源: https://blog.csdn.net/qq_40685439/article/details/116451397