From 81b1d49e84e29a5bf61882e7aef780a2a461f802 Mon Sep 17 00:00:00 2001 From: bobi Date: Fri, 17 May 2019 17:16:54 +0800 Subject: [PATCH] add parameterCheck --- lib/okplugins/okTab.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/okplugins/okTab.js b/lib/okplugins/okTab.js index 3301954..2ce4207 100644 --- a/lib/okplugins/okTab.js +++ b/lib/okplugins/okTab.js @@ -6,7 +6,11 @@ layui.define(["element", "layer"], function (exports) { var okTab = { add: function (title, path, tabId) { - console.log(title, path, tabId); + console.log("title:", title, "path:", path, "tabId:", tabId); + // 参数校验 + if (!okTab.parameterCheck(title, path, tabId)) { + return false; + } // 去重复选项卡 var okFrame = $(".ok-frame", window.top.document); for (var i = 0; i < okFrame.length; i++) { @@ -25,7 +29,22 @@ layui.define(["element", "layer"], function (exports) { }); // 切换选项卡 element.tabChange("ok-tab", tabId); - } + }, + parameterCheck: function(title, path, tabId) { + if (title == undefined || title == "") { + console.error("title未定义") + return false; + } + if (path == undefined || path == "") { + console.error("path未定义") + return false; + } + if (tabId == undefined || tabId == "") { + console.error("tabId未定义") + return false; + } + return true; + } } exports("okTab", okTab);