From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 28 五月 2025 16:48:52 +0800 Subject: [PATCH] 初始化项目 --- uview-ui/libs/function/trim.js | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/uview-ui/libs/function/trim.js b/uview-ui/libs/function/trim.js new file mode 100644 index 0000000..72adc37 --- /dev/null +++ b/uview-ui/libs/function/trim.js @@ -0,0 +1,15 @@ +function trim(str, pos = 'both') { + if (pos == 'both') { + return str.replace(/^\s+|\s+$/g, ""); + } else if (pos == "left") { + return str.replace(/^\s*/, ''); + } else if (pos == 'right') { + return str.replace(/(\s*$)/g, ""); + } else if (pos == 'all') { + return str.replace(/\s+/g, ""); + } else { + return str; + } +} + +export default trim -- Gitblit v1.9.3