From 084776ccd3c247bd89b76e0859b379772287f75c Mon Sep 17 00:00:00 2001 From: the1812 Date: Sat, 12 Mar 2022 17:13:28 +0800 Subject: [PATCH] Add oldValue in validator --- src/components/types.ts | 2 +- src/ui/text-control.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/types.ts b/src/components/types.ts index 16f815ec9..a16060274 100644 --- a/src/components/types.ts +++ b/src/components/types.ts @@ -42,7 +42,7 @@ export interface ComponentTag { /** 设置面板中的呈现顺序 */ order: number } -type ComponentOptionValidator = (value: T) => T | undefined | null +type ComponentOptionValidator = (value: T, oldValue: T) => T | undefined | null /** 组件选项信息 * @todo 需要 extends 出更具体的 Option 类型, 现在这样混一起太乱 */ diff --git a/src/ui/text-control.ts b/src/ui/text-control.ts index a3fad8bd0..d5d4c1fe1 100644 --- a/src/ui/text-control.ts +++ b/src/ui/text-control.ts @@ -33,7 +33,7 @@ export const textControlMixin = Vue.extend({ emitChange() { let { value } = this.$refs.input if (this.validator) { - value = this.validator(value) + value = this.validator(value, this.text) if (this.changeOnBlur) { this.$refs.input.value = value }