Add oldValue in validator

This commit is contained in:
the1812 2022-03-12 17:13:28 +08:00
parent 767edadfaa
commit 084776ccd3
2 changed files with 2 additions and 2 deletions

View File

@ -42,7 +42,7 @@ export interface ComponentTag {
/** 设置面板中的呈现顺序 */ /** 设置面板中的呈现顺序 */
order: number order: number
} }
type ComponentOptionValidator<T> = (value: T) => T | undefined | null type ComponentOptionValidator<T> = (value: T, oldValue: T) => T | undefined | null
/** /**
* @todo extends Option , * @todo extends Option ,
*/ */

View File

@ -33,7 +33,7 @@ export const textControlMixin = Vue.extend({
emitChange() { emitChange() {
let { value } = this.$refs.input let { value } = this.$refs.input
if (this.validator) { if (this.validator) {
value = this.validator(value) value = this.validator(value, this.text)
if (this.changeOnBlur) { if (this.changeOnBlur) {
this.$refs.input.value = value this.$refs.input.value = value
} }