Bootstrap-Fileinput 預覽圖不生效不顯示圖片


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM