layui 外部调用use内定义的函数

外部调用layui.use内定义的函数需要引入 layui.all.js ,并定义 window.xxx函数

window.ajaxSubmit = function(data,url,type){
    $.ajax({
        url: url,
        data: data,
        type: type,
        async: false,
        success:function(res) {
            if(res.code == 1) {
                layer.alert(res.msg, function(index){
                    location.href = res.url;
                })
            } else {
                layer.msg(res.msg);
            }
        }
    });
}

猜你喜欢

转载自blog.csdn.net/qazx123q/article/details/80049921