FastAdmin 修改上传组件预览方式


在\public\assets\js\backend-init.js中添加以下函数

$('body').on('click', '[data-tips-image]', function () {
                var img = new Image();
                var imgWidth = this.getAttribute('data-width') || '480px';
                img.onload = function () {
                    var $content = $(img).appendTo('body').css({background: '#fff', width: imgWidth, height: 'auto'});
                    Layer.open({
                        type: 1, area: imgWidth, title: false, closeBtn: 1,
                        skin: 'layui-layer-nobg', shadeClose: true, content: $content,
                        end: function () {
                            $(img).remove();
                        },
                        success: function () {

                        }
                    });
                };
                img.onerror = function (e) {

                };
                img.src = this.getAttribute('data-url') || this.src;
            });

在\public\assets\js\require-upload.js中修改以下内容

                previewtpl: '
  • \';this.onerror=null;" class="img-responsive">
  • ', //previewtpl: '
  • \';this.onerror=null;" class="img-responsive">
  • ',