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

 

posted @ 2020-08-21 10:08  千夜大魔王  阅读(2584)  评论(0编辑  收藏  举报