File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ borderless | Boolean | false | 是否开启无边框模式 | N
14
14
clearTrigger | String | always | 清空图标触发方式,仅在输入框有值时有效。可选项:always / focus | N
15
15
clearable | Boolean | false | 是否可清空 | N
16
16
disabled | Boolean | undefined | 是否禁用输入框 | N
17
- format | Function | - | 【开发中】 指定输入框展示值的格式。TS 类型:` InputFormatType ` ` type InputFormatType = (value: InputValue) => string ` 。[ 详细类型定义] ( https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/input/type.ts ) | N
17
+ format | Function | - | 指定输入框展示值的格式。TS 类型:` InputFormatType ` ` type InputFormatType = (value: InputValue) => string ` 。[ 详细类型定义] ( https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/input/type.ts ) | N
18
18
label | String / Slot / Function | - | 左侧文本。TS 类型:` string \| TNode ` 。[ 通用类型定义] ( https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts ) | N
19
19
layout | String | horizontal | 标题输入框布局方式。可选项:vertical/horizontal | N
20
20
maxcharacter | Number | - | 用户最多可以输入的字符个数,一个中文汉字表示两个字符长度。` maxcharacter ` 和 ` maxlength ` 二选一使用 | N
Original file line number Diff line number Diff line change 4
4
BrowseOffIcon as TBrowseOffIcon ,
5
5
CloseCircleFilledIcon as TCloseCircleFilledIcon ,
6
6
} from 'tdesign-icons-vue-next' ;
7
+ import isFunction from 'lodash/isFunction' ;
7
8
import config from '../config' ;
8
9
import InputProps from './props' ;
9
10
import { InputValue , TdInputProps } from './type' ;
@@ -132,6 +133,17 @@ export default defineComponent({
132
133
133
134
const handleBlur = ( e : FocusEvent ) => {
134
135
focused . value = false ;
136
+
137
+ // 失焦时处理 format
138
+ if ( isFunction ( props . format ) ) {
139
+ innerValue . value = props . format ( innerValue . value ) ;
140
+ nextTick ( ( ) => {
141
+ setInputValue ( innerValue . value ) ;
142
+ props . onBlur ?.( innerValue . value , { e } ) ;
143
+ } ) ;
144
+ return ;
145
+ }
146
+
135
147
props . onBlur ?.( innerValue . value , { e } ) ;
136
148
} ;
137
149
You can’t perform that action at this time.
0 commit comments