繁体   English   中英

Vue.js slider 与本地图像不起作用

[英]Vue.js slider with local image doesn't work

嗨,我在“digitalocean.com”上找到了 Vue.js 的这张图片 slider,但仅适用于上传到(imgbb、pixabay 等)的图片。 我尝试使用本地图像(在资产上)设置但不起作用,有人可以帮助我吗? 我已经尝试过../assets/castelgandolfo.jpg 或./assets/castelgandolfo.jpg 对不起我的英语!

这是代码:

 export default { name: "Slider", data() { return { images: [ "https://i.ibb.co/6NJ7p6w/Castelgandolfo.jpg", "https://i.ibb.co/QJN06cG/Grottaferrata.jpg", "https://i.ibb.co/R3pHtGx/Ariccia.jpg", ], timer: null, currentIndex: 0 }; }, mounted: function() { this.startSlide(); }, methods: { startSlide: function() { this.timer = setInterval(this.next, 10000); }, next: function() { this.currentIndex += 1; }, prev: function() { this.currentIndex -= 1; } }, computed: { currentImg: function() { return this.images[Math.abs(this.currentIndex) % this.images.length]; } } };

您可以使用“@”直接引用图像

例子:

<img src="@/assets/images/home.png"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM