layui使用上传组件和穿梭框报错,看错误应该跟我项目有关,又像是js文件直接有冲突

提问 未结 3 225
Oamha
Oamha 2019-6-20
悬赏:20飞吻
版本:layui 浏览器:



layui使用上传组件和穿梭框报错,看错误应该跟我项目有关,又像是js文件之间有冲突
回帖
  • mengyan
    2019-6-20
    你单发一个这样的错误是没办法解决的,最起码发一段源码什么的吧
    0 回复
  • Oamha
    2019-6-20
    @mengyan
     大佬帮忙看一下
    <script>
    layui.use(['element', 'form', 'upload', 'layer'], function () {
    var element = layui.element;
    var form = layui.form;
    var upload = layui.upload;
    var layer = layui.layer;
    var $ = layui.jquery;
    layer.config({
    anim: 6,
    offset: ['46%', '31%']
    })


    //文件上传
    var uploadInst = upload.render({
    elem: '#avatar-upload',
    url: '${pageContext.request.contextPath}/user/avatar',
    field: "avatar",
    method: "post",
    auto: false,
    acceptMime: "image/*",
    bindAction: "#startBtn",
    choose: function (obj) {
    obj.preview(function (index, file, result) {
    $('#userAvatar').attr('src', result);
    });
    },

    done: function (res) {
    if (res.code != 0) {
    layer.msg(res.msg, {
    time: 1000,
    anim: 6
    })
    } else {
    layer.msg(res.msg, {
    time: 1000,
    anim: 5,
    offset: ['50%', '36%']
    }, function () {
    window.location.href = "${pageContext.request.contextPath}/user/info";
    })
    }
    }
    });

    });
    </script>
    0 回复
  • star1029
    2019-6-25
    @Oamha 你那个 bbs 是什么
    0 回复