From 3d250211d713d6bec7e08fe130f127df239c89dc Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 12 Sep 2019 10:16:59 +0800 Subject: [PATCH] =?UTF-8?q?BI-50878=20refactor:=20BI=E5=92=8C=E7=89=A9?= =?UTF-8?q?=E6=96=99=E5=BA=93=E4=B8=AD=E9=83=BD=E6=98=AF=E7=94=A8=E7=9A=84?= =?UTF-8?q?getGBWidth=E6=94=BE=E5=88=B0fineui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/func/function.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/func/function.js b/src/core/func/function.js index 1a26b49815..b2d65b6f5a 100644 --- a/src/core/func/function.js +++ b/src/core/func/function.js @@ -23,6 +23,18 @@ _.extend(BI.Func, { } return name; }, + + /** + * 获取字符宽度 + * @param str + * @return {number} + */ + getGBWidth: function (str) { + str = str + ""; + str = str.replace(/[^\x00-\xff]/g, "xx"); + return Math.ceil(str.length / 2); + }, + /** * 获取搜索结果 * @param items