layui 弹窗 area属性 内外自适应问题解决方法

审核中 layui.js 未结 已结 置顶 精帖
删除 置顶 取消置顶 加精 取消加精
66 0
yswl
yswl VIP3 2023-02-13 09:34:36
悬赏:60金币 编辑此贴

layui 弹窗 area属性 内外自适应问题解决方法

 function showDialog() {
        layer.ready(function () {
          var area = ["50%", "60%"];
         
          if ($(document).height() <= 768){ //避免pc分辨率过小1366x680
            area = ["80%", "95%"];
          }
            layer.open({
              type: 1,
              title: "抉择解决人",
              id: "handler",
              area: area,
              content: $("#dialogTree"),
              btn: ["确定", "勾销"],
              zIndex: layer.zIndex,
              success: function (layero) {
                //成功后的执行
              },
              end: function () {},
              btnAlign: "c",
              yes: function (index, layero) {
                //按钮【确认】的回调
               ...
                layer.close(index);
              },
              btn2: function (index, layero) {
                //按钮【勾销】的回调
              },
            });
        });
      };