mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[Improvement] Field: add confirm type
This commit is contained in:
parent
553628143d
commit
4f04f8a61f
@ -142,6 +142,7 @@
|
|||||||
| autosize | 自适应内容高度,只对 textarea 有效 | `Boolean` | `false` |
|
| autosize | 自适应内容高度,只对 textarea 有效 | `Boolean` | `false` |
|
||||||
| icon | 输入框尾部图标 (可选值见 Icon 组件) | `String` | - |
|
| icon | 输入框尾部图标 (可选值见 Icon 组件) | `String` | - |
|
||||||
| left-icon | 输入框左侧图标 (可选值见 Icon 组件) | `String` | - |
|
| left-icon | 输入框左侧图标 (可选值见 Icon 组件) | `String` | - |
|
||||||
|
| confirm-type | 设置键盘右下角按钮的文字,仅在 type='text' 时生效 | `String` | `done` |
|
||||||
| cursor-spacing | 输入框聚焦时底部与键盘的距离 | `Number` | `50` |
|
| cursor-spacing | 输入框聚焦时底部与键盘的距离 | `Number` | `50` |
|
||||||
| use-button-slot | 是否使用 button slot | `Boolean` | `false` |
|
| use-button-slot | 是否使用 button slot | `Boolean` | `false` |
|
||||||
|
|
||||||
@ -149,8 +150,9 @@
|
|||||||
|
|
||||||
| 事件 | 说明 | 回调参数 |
|
| 事件 | 说明 | 回调参数 |
|
||||||
|-----------|-----------|-----------|
|
|-----------|-----------|-----------|
|
||||||
| inout | 输入内容时触发 | value: 当前输入值 |
|
| input | 输入内容时触发 | value: 当前输入值 |
|
||||||
| change | 输入内容时触发 | value: 当前输入值 |
|
| change | 输入内容时触发 | value: 当前输入值 |
|
||||||
|
| confirm | 点击完成按钮时触发 | value: 当前输入值 |
|
||||||
| tap-icon | 点击尾部图标时触发 | - |
|
| tap-icon | 点击尾部图标时触发 | - |
|
||||||
| focus | 输入框聚焦时触发 | - |
|
| focus | 输入框聚焦时触发 | - |
|
||||||
| blur | 输入框失焦时触发 | - |
|
| blur | 输入框失焦时触发 | - |
|
||||||
|
@ -2,7 +2,6 @@ Component({
|
|||||||
behaviors: ['wx://form-field'],
|
behaviors: ['wx://form-field'],
|
||||||
|
|
||||||
externalClasses: [
|
externalClasses: [
|
||||||
'custom-class',
|
|
||||||
'input-class'
|
'input-class'
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -26,8 +25,11 @@ Component({
|
|||||||
clearable: Boolean,
|
clearable: Boolean,
|
||||||
labelAlign: String,
|
labelAlign: String,
|
||||||
inputAlign: String,
|
inputAlign: String,
|
||||||
|
customClass: String,
|
||||||
|
confirmType: String,
|
||||||
errorMessage: String,
|
errorMessage: String,
|
||||||
placeholder: String,
|
placeholder: String,
|
||||||
|
customStyle: String,
|
||||||
useButtonSlot: Boolean,
|
useButtonSlot: Boolean,
|
||||||
placeholderClass: String,
|
placeholderClass: String,
|
||||||
cursorSpacing: {
|
cursorSpacing: {
|
||||||
@ -40,15 +42,15 @@ Component({
|
|||||||
},
|
},
|
||||||
value: {
|
value: {
|
||||||
type: null,
|
type: null,
|
||||||
value: ''
|
value: '',
|
||||||
},
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
value: 'text',
|
|
||||||
observer(currentValue) {
|
observer(currentValue) {
|
||||||
this.setData({ currentValue });
|
this.setData({ currentValue });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
value: 'text'
|
||||||
|
},
|
||||||
border: {
|
border: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: true
|
value: true
|
||||||
@ -113,6 +115,12 @@ Component({
|
|||||||
currentValue: '',
|
currentValue: '',
|
||||||
showClear: this.getShowClear({ value: '' })
|
showClear: this.getShowClear({ value: '' })
|
||||||
});
|
});
|
||||||
|
this.triggerEvent('input', '');
|
||||||
|
this.triggerEvent('change', '');
|
||||||
|
},
|
||||||
|
|
||||||
|
onConfirm() {
|
||||||
|
this.triggerEvent('confirm', this.data.currentValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
border="{{ border }}"
|
border="{{ border }}"
|
||||||
is-link="{{ isLink }}"
|
is-link="{{ isLink }}"
|
||||||
required="{{ required }}"
|
required="{{ required }}"
|
||||||
|
custom-style="{{ customStyle }}"
|
||||||
title-width="90px"
|
title-width="90px"
|
||||||
custom-class="custom-class van-field {{ labelAlign ? 'van-field--label-' + labelAlign : '' }}"
|
custom-class="{{ customClass }} van-field {{ labelAlign ? 'van-field--label-' + labelAlign : '' }}"
|
||||||
>
|
>
|
||||||
<slot name="label" slot="title" />
|
<slot name="label" slot="title" />
|
||||||
<view class="van-field__body {{ type === 'textarea' ? 'van-field__body--textarea' : '' }}">
|
<view class="van-field__body {{ type === 'textarea' ? 'van-field__body--textarea' : '' }}">
|
||||||
@ -23,8 +24,9 @@
|
|||||||
placeholder-class="{{ placeholderClass }} {{ error ? 'van-field--error' : '' }}"
|
placeholder-class="{{ placeholderClass }} {{ error ? 'van-field--error' : '' }}"
|
||||||
cursor-spacing="{{ cursorSpacing }}"
|
cursor-spacing="{{ cursorSpacing }}"
|
||||||
bindinput="onInput"
|
bindinput="onInput"
|
||||||
bind:focus="onFocus"
|
|
||||||
bind:blur="onBlur"
|
bind:blur="onBlur"
|
||||||
|
bind:focus="onFocus"
|
||||||
|
bind:confirm="onConfirm"
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
wx:else
|
wx:else
|
||||||
@ -37,10 +39,12 @@
|
|||||||
maxlength="{{ maxlength }}"
|
maxlength="{{ maxlength }}"
|
||||||
placeholder="{{ placeholder }}"
|
placeholder="{{ placeholder }}"
|
||||||
placeholder-class="{{ placeholderClass }} {{ error ? 'van-field--error' : '' }}"
|
placeholder-class="{{ placeholderClass }} {{ error ? 'van-field--error' : '' }}"
|
||||||
|
confirm-type="{{ confirmType }}"
|
||||||
cursor-spacing="{{ cursorSpacing }}"
|
cursor-spacing="{{ cursorSpacing }}"
|
||||||
bindinput="onInput"
|
bindinput="onInput"
|
||||||
bind:focus="onFocus"
|
|
||||||
bind:blur="onBlur"
|
bind:blur="onBlur"
|
||||||
|
bind:focus="onFocus"
|
||||||
|
bind:confirm="onConfirm"
|
||||||
/>
|
/>
|
||||||
<van-icon
|
<van-icon
|
||||||
wx:if="{{ showClear }}"
|
wx:if="{{ showClear }}"
|
||||||
@ -51,8 +55,8 @@
|
|||||||
<view class="van-field__icon-container" bind:tap="onTapIcon">
|
<view class="van-field__icon-container" bind:tap="onTapIcon">
|
||||||
<van-icon
|
<van-icon
|
||||||
wx:if="{{ icon }}"
|
wx:if="{{ icon }}"
|
||||||
custom-class="van-field__icon {{ iconClass }}"
|
|
||||||
name="{{ icon }}"
|
name="{{ icon }}"
|
||||||
|
custom-class="van-field__icon {{ iconClass }}"
|
||||||
/>
|
/>
|
||||||
<slot wx:else name="icon" />
|
<slot wx:else name="icon" />
|
||||||
</view>
|
</view>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user