我所試圖做的是從目錄中加載的所有文件(圖像)和每幅圖像上追加了光滑的滑塊。我初始化js文件中準備好的滑塊,在初始化後我調用函數addImagestoSlider()。當我在本地測試站點時(這些圖像被顯示),這個工作正常,但是當我將它轉換爲螺栓cms時,圖像不會顯示在滑塊中。我可以在檢查元素中看到圖像,但不顯示。油滑滑塊不螺栓CMS顯示圖像
JavaScript函數:
function addImagesToSlider() {
console.log("in addImagesToSlider");
var dirCars = "http://localhost/bolt/public/bolt/files/files/Cars";
const fileextension = ".jpg";
$.ajax({
//This will retrieve the contents of the folder if the folder is configured as 'browsable'
url: dirCars,
success: function success(data) {
//List all .jpg file names in the page
$(data).find("a:contains(" + fileextension + ")").each(function() {
let filename = this.href.replace(window.location.host, "").replace("http://", "");
console.log("filename: " + filename);
$('#cars_slider .slide-tracker').append(`
<figure>
<img src="${filename}"
</figure>
`);
});
}
});
}