From d66801ac344a65db3e7b1a11885e18f98db76f59 Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Thu, 27 Feb 2020 18:40:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA=20equal=20?= =?UTF-8?q?=E7=9A=84=E7=94=A8=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/tpl-builtin.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utils/tpl-builtin.ts b/src/utils/tpl-builtin.ts index 6a321684..659eb9ea 100644 --- a/src/utils/tpl-builtin.ts +++ b/src/utils/tpl-builtin.ts @@ -238,6 +238,17 @@ export const filters: { fn = value => !value; } else if (directive === 'isExists') { fn = value => typeof value !== 'undefined'; + } else if (directive === 'equals' || directive === 'equal') { + arg1 = arg1 + ? /^('|")(.*)\1$/.test(arg1) + ? RegExp.$2 + : resolveVariable(arg1, this as any) + : ''; + // 比对的值是空时直接返回。 + if (!arg1) { + return input; + } + fn = value => arg1 == value; } else { if (directive !== 'match') { directive = 'match';