data中的路径只会被当做普通的字符串,因此无法获取图片
data () {
return {
carousels: [
"../assets/img/carousel_1.png",
"../assets/img/carousel_2.png",
"../assets/img/carousel_3.png",
"../assets/img/carousel_4.png"
]
}
}
在data中的路径应写为:
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")
]
}
}