From d7b9586e7e6c0fc62b0f8e326fc7c94c402768e2 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Tue, 08 Mar 2022 15:38:59 +0800 Subject: [PATCH] 优化注释 --- common/Tools.js | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/common/Tools.js b/common/Tools.js index 476235e..e4e7403 100644 --- a/common/Tools.js +++ b/common/Tools.js @@ -28,7 +28,11 @@ * @param {String} [search] * @return {String|Null} */ - static getUrlParam(name, search = window.location.search) { + static getUrlParam(name, search) { + if (process.env.TARO_ENV === 'weapp') { + return null; + } + search = search || window.location.search; const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); const r = search.substr(1).match(reg); if (r !== null) { @@ -119,12 +123,21 @@ } /** + * 判断是否为未定义 + * @param {*} data + * @return {Boolean} + */ + static isUndefined(data) { + return Object.prototype.toString.call(data) === '[object Undefined]'; + } + + /** * 判断是否为 null * @param {*} data * @return {Boolean} */ static isNull(data) { - return data === null; + return Object.prototype.toString.call(data) === '[object Null]'; } /** @@ -348,7 +361,7 @@ if (minutes) { words = minutes + '分' + words; } - const hours = duration.get('hours'); + const hours = parseInt(duration.as('hours')); if (hours) { words = hours + '小时' + words; } -- Gitblit v1.9.1