//用下面的方法得到当前TAB的总数量

 

var tabcount = $('#tabs').tabs('tabs').length;
修改addTab 方法为:

 

function addTab(subtitle, url, icon) {
    var tabCount = $('#tabs').tabs('tabs').length;  // 获取当前打开窗口总数量
    var hasTab = $('#tabs').tabs('exists', subtitle); //根据名称判断窗口是否已打开
    var add = function () {
        if (!hasTab) {
            $('#tabs').tabs('add', {
                title: subtitle,
                content: createFrame(url),
                closable: true,
                icon: icon
            });
        } else {
            $('#tabs').tabs('select', subtitle);
            $('#mm-refresh').click();
        }
    }

    if (tabCount > 5 && !hasTab) {
        var msg = '您当前打开了太多的页面,如果继续打开,会造成程序运行缓慢,无法流畅操作!'
        $.messager.confirm("系统提示", msg, function (b) {
            if (b) add();
            else return false;
        })
    } else {
        add();
    }

   
   tabClose();

}

这样允许打开的最大数量为5个(不包括欢迎页)。可根据需要自行修改

 

相关文章:

  • 2021-09-17
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2021-07-10
  • 2022-01-22
  • 2022-12-23
猜你喜欢
  • 2021-12-10
  • 2021-07-05
  • 2022-12-23
  • 2021-06-15
  • 2021-11-13
  • 2022-12-23
  • 2021-07-15
相关资源
相似解决方案