1
- import { PropType , ref , computed , defineComponent , nextTick , watch } from 'vue' ;
1
+ import { PropType , ref , computed , defineComponent , nextTick , watch , inject } from 'vue' ;
2
2
import {
3
3
BrowseIcon as TBrowseIcon ,
4
4
BrowseOffIcon as TBrowseOffIcon ,
@@ -9,6 +9,7 @@ import config from '../config';
9
9
import InputProps from './props' ;
10
10
import { InputValue , TdInputProps } from './type' ;
11
11
import { getCharacterLength , useDefault , extendAPI } from '../shared' ;
12
+ import { FormItemInjectionKey } from '../form/const' ;
12
13
import { useFormDisabled } from '../form/hooks' ;
13
14
import { usePrefixClass } from '../hooks/useClass' ;
14
15
import { useTNodeJSX } from '../hooks/tnode' ;
@@ -45,6 +46,7 @@ export default defineComponent({
45
46
const status = props . status || 'default' ;
46
47
const renderType = ref ( props . type ) ;
47
48
const focused = ref ( false ) ;
49
+ const formItem = inject ( FormItemInjectionKey , undefined ) ;
48
50
49
51
const inputClasses = computed ( ( ) => [
50
52
`${ inputClass . value } __control` ,
@@ -133,18 +135,19 @@ export default defineComponent({
133
135
134
136
const handleBlur = ( e : FocusEvent ) => {
135
137
focused . value = false ;
136
-
137
138
// 失焦时处理 format
138
139
if ( isFunction ( props . format ) ) {
139
140
innerValue . value = props . format ( innerValue . value ) ;
140
141
nextTick ( ( ) => {
141
142
setInputValue ( innerValue . value ) ;
142
143
props . onBlur ?.( innerValue . value , { e } ) ;
144
+ formItem . handleBlur ( ) ;
143
145
} ) ;
144
146
return ;
145
147
}
146
148
147
149
props . onBlur ?.( innerValue . value , { e } ) ;
150
+ formItem . handleBlur ( ) ;
148
151
} ;
149
152
150
153
const handleCompositionend = ( e : CompositionEvent ) => {
0 commit comments