简体   繁体   English

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

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

Hi i find this image slider for Vue.js on "digitalocean.com" but works only with image uploaded on (imgbb, pixabay, etc).嗨,我在“digitalocean.com”上找到了 Vue.js 的这张图片 slider,但仅适用于上传到(imgbb、pixabay 等)的图片。 i try to set with local image (on assets) but doesn't work, some one can help me?我尝试使用本地图像(在资产上)设置但不起作用,有人可以帮助我吗? i already tried with../assets/castelgandolfo.jpg or./assets/castelgandolfo.jpg sorry for my english!我已经尝试过../assets/castelgandolfo.jpg 或./assets/castelgandolfo.jpg 对不起我的英语!

This is the code:这是代码:

 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]; } } };

You can refer images directly using '@'您可以使用“@”直接引用图像

Example:例子:

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

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

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