簡體   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