使用layui前端模块化框架报错:layer is not defined

解决方法:需要使用layer对象,需先初始化,如下:

layui.use('layer', function () {
    var layer = layui.layer;
    layer.open({
    });
});
 /*跳转网页*/
    function goOtherWebsite(websiteName, websiteUrl) {
        layui.use('layer', function () {
            var layer = layui.layer;

            layer.open({
                icon: 1, // 皮肤样式
                content: '将跳转至第三方:“' + websiteName + '”网站,是否跳转?',//提示信息
                type: 0,
                btn: ['确定', '取消'],
                fix: true, //固定
                scrollbar: false,//滚动条
                yes: function (index) { // 点击确定按钮
                    // window.location.href = websiteUrl;
                    window.open(websiteUrl);

                    //最后关闭弹出层
                    layer.close(index);
                },
                // end 函数执行的是弹框关闭时触发的事件
                end: function () { // 未点击确定按钮,点击关闭按钮
                    // $("#mainForm").submit();
                }
            });
        });
    }

 

相关文章:

  • 2021-11-17
  • 2022-03-06
  • 2021-12-31
  • 2021-06-16
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
猜你喜欢
  • 2021-04-24
  • 2022-02-26
  • 2022-12-23
  • 2021-04-08
  • 2021-12-05
  • 2021-11-29
相关资源
相似解决方案