LiuBei

青春渐行渐远,一去不复返 用有限的时间来记录那些无限美好的事情

layer ui upload上传中无法获取动态参数

传值时使用函数就可以了


layui.use('upload', function(){
    var upload = layui.upload;
    var uploadInst = upload.render({
        elem: '#headimgurluploadImg',
        url: "{:url('upload/uploadAuto')}",
        data:{path: function(){return $('#filePath').val();}},
        before:function(){
            var filePath = $('#filePath').val();
            if(filePath == '') {
                layer.msg('请选择或手动填写一个上传路径后在提交',{icon:2});
                return false;
            }
        },
        done: function(res){
            if(!res.code) {
                layer.msg(res.msg,{icon:2});
            }
            else {
                layer.msg(res.msg,{icon:1});
                setTimeout(function(){
                    location.href = '?path='+$('#filePath').val();
                },1000);
            }
        },
        error: function(res){
            layer.msg('请求异常',{icon:2});
        }
    });
});




分享文章
0 条评论