mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
parent
14b5c0a9e4
commit
686b497c58
@ -47,7 +47,15 @@ export default {
|
|||||||
:on-icon-click="onIconClick"
|
:on-icon-click="onIconClick"
|
||||||
@blur="onFieldBlur"
|
@blur="onFieldBlur"
|
||||||
required></van-field>
|
required></van-field>
|
||||||
<van-field type="password" label="密码:" placeholder="请输入密码" required></van-field>
|
<van-field
|
||||||
|
type="password"
|
||||||
|
label="密码:"
|
||||||
|
placeholder="请输入密码"
|
||||||
|
required>
|
||||||
|
<template slot="icon">
|
||||||
|
<van-icon name="search"></van-icon>
|
||||||
|
</template>
|
||||||
|
</van-field>
|
||||||
<van-field type="textarea" label="个人介绍:" placeholder="请输入个人介绍" required></van-field>
|
<van-field type="textarea" label="个人介绍:" placeholder="请输入个人介绍" required></van-field>
|
||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
```
|
```
|
||||||
@ -132,3 +140,9 @@ export default {
|
|||||||
| icon | 输入框尾部图标 | `string` | | icon中支持的类型 |
|
| icon | 输入框尾部图标 | `string` | | icon中支持的类型 |
|
||||||
| onIconClick | 点击图标的回调函数 | `function` | | |
|
| onIconClick | 点击图标的回调函数 | `function` | | |
|
||||||
|
|
||||||
|
### Slot
|
||||||
|
|
||||||
|
| name | 描述 |
|
||||||
|
|-----------|-----------|
|
||||||
|
| icon | 自定义icon |
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
'van-field--disabled': disabled,
|
'van-field--disabled': disabled,
|
||||||
'van-field--error': error,
|
'van-field--error': error,
|
||||||
'van-field--border': border,
|
'van-field--border': border,
|
||||||
'van-field--autosize': autosize
|
'van-field--autosize': autosize,
|
||||||
|
'van-field--has-icon': showIcon
|
||||||
}">
|
}">
|
||||||
<textarea
|
<textarea
|
||||||
v-if="type === 'textarea'"
|
v-if="type === 'textarea'"
|
||||||
@ -37,7 +38,11 @@
|
|||||||
:maxlength="maxlength"
|
:maxlength="maxlength"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:readonly="readonly">
|
:readonly="readonly">
|
||||||
<van-icon v-if="icon && currentValue" :name="icon" class="van-field__icon" @click="onIconClick"></van-icon>
|
<div v-if="showIcon" class="van-field__icon" @click="onIconClick">
|
||||||
|
<slot name="icon">
|
||||||
|
<van-icon :name="icon"></van-icon>
|
||||||
|
</slot>
|
||||||
|
</div>
|
||||||
</van-cell>
|
</van-cell>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -101,6 +106,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
showIcon() {
|
||||||
|
// 有icon的slot,就认为一直展示
|
||||||
|
if (this.$slots.icon) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.icon && this.currentValue;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
handleInput(event) {
|
handleInput(event) {
|
||||||
this.currentValue = event.target.value;
|
this.currentValue = event.target.value;
|
||||||
|
@ -78,6 +78,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&--has-icon {
|
||||||
|
.van-field__control {
|
||||||
|
width: 90%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&__control {
|
&__control {
|
||||||
border: 0;
|
border: 0;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user