From 7c48f9178c11e3e05a34a082a3e2f97e3c2da3cd Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Wed, 30 Oct 2019 20:06:48 +0800 Subject: [PATCH] =?UTF-8?q?filter=20=E5=9C=A8=E5=A4=84=E7=90=86=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E6=97=B6=E4=B8=8E=E5=8E=9F=E6=9D=A5=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/tpl-builtin.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utils/tpl-builtin.ts b/src/utils/tpl-builtin.ts index 3b731eea..c888cba2 100644 --- a/src/utils/tpl-builtin.ts +++ b/src/utils/tpl-builtin.ts @@ -232,7 +232,16 @@ export const filters: { arg1 = expOrDirective; } arg1 = arg1 ? (/^('|")(.*)\1$/.test(arg1) ? RegExp.$2 : resolveVariable(arg1, this as any)) : ''; - fn = value => !!~String(value).toLowerCase().indexOf(arg1); + + // 比对的值是空时直接返回。 + if (!arg1) { + return input; + } + + fn = value => + !!~String(value) + .toLowerCase() + .indexOf(arg1); } keys = keys.split(/\s*,\s*/);