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