springboot項目Thymeleaf從后台獲取取到圖片鏈接后,進行初始化Bootstrap-Fileinput ,拼接字符串放到initialPreview顯示失敗
我翻了挺久找不到教程,預覽圖顯示鏈接地址,不顯示圖片!!!
直接上代碼:
var url1=[]; url1.push("圖片地址"); //初始化 $input1.fileinput({//開票資料 uploadUrl: ctx + "freight/proxyInfo/uploadInvoiceInformation", // 服務器接收上傳文件的方法 uploadAsync: false, dropZoneTitle:'拖拽文件到這里,上傳文件', showUpload: false, // 隱藏上傳按鈕 showRemove: false, // 隱藏移除按鈕 showPreview:true, maxFileCount:1, showCaption:true, autoReplace:true, //主要是下面三個設置 initialPreviewAsData: true, initialPreviewFileType: 'image', initialPreview: [url1] }).on("filebatchselected", function(event, files) { // 選擇文件后立即觸發上傳方法 $input1.fileinput("upload"); }).on("filebatchuploadsuccess", function(event, data) { //當上傳成功回調函數 $("#invoiceInformation").val(data.response.msg); });