mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(field): add custom-class prop support (#5476)
This commit is contained in:
parent
fa04172e5b
commit
8309c27297
@ -16,7 +16,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
@ -125,7 +125,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
@ -234,7 +234,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
@ -343,7 +343,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
|
@ -17,7 +17,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<van-field>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell"
|
||||
@ -197,7 +197,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</van-field>
|
||||
<van-field>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
@ -373,7 +373,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<van-field>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell"
|
||||
@ -553,7 +553,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</van-field>
|
||||
<van-field>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
|
@ -186,7 +186,14 @@ Page({
|
||||
在微信小程序中,bind:input 事件可以通过返回字符串或者一个对象来替换输入框的值以及调整光标的位置,在 vant-weapp 中,可以通过调用 change 或 input 参数中的 callback 函数,传入参数来实现
|
||||
|
||||
```html
|
||||
<van-field value="{{ value }}" placeholder="请输入用户名" border="{{ false }}" clearable extra-event-params bind:change="onChange" />
|
||||
<van-field
|
||||
value="{{ value }}"
|
||||
placeholder="请输入用户名"
|
||||
border="{{ false }}"
|
||||
clearable
|
||||
extra-event-params
|
||||
bind:change="onChange"
|
||||
/>
|
||||
```
|
||||
|
||||
```js
|
||||
@ -199,9 +206,9 @@ Page({
|
||||
|
||||
callback({
|
||||
value: value + 1,
|
||||
cursor: 0
|
||||
})
|
||||
}
|
||||
cursor: 0,
|
||||
});
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
@ -289,7 +296,7 @@ Page({
|
||||
| 事件 | 说明 | 回调参数 |
|
||||
| --- | --- | --- |
|
||||
| bind:input | 输入内容时触发 | event.detail: 当前输入值; 在 extra-event-params 为 `true` 时为 [InputDetail](#/field#inputdetail) |
|
||||
| bind:change | 输入内容时触发 | event.detail: 当前输入值; 在 extra-event-params 为 `true` 时为 [InputDetail](#/field#inputdetail) |
|
||||
| bind:change | 输入内容时触发 | event.detail: 当前输入值; 在 extra-event-params 为 `true` 时为 [InputDetail](#/field#inputdetail) |
|
||||
| bind:confirm | 点击完成按钮时触发 | event.detail: 当前输入值 |
|
||||
| bind:click-icon | 点击尾部图标时触发 | - |
|
||||
| bind:focus | 输入框聚焦时触发 | event.detail.value: 当前输入值; <br>event.detail.height: 键盘高度 |
|
||||
@ -300,12 +307,13 @@ Page({
|
||||
| bind:keyboardheightchange | 键盘高度发生变化的时候触发此事件 | event.detail = { height: height, duration: duration } |
|
||||
|
||||
### InputDetail
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| value | 当前输入值 | _string_ | - |
|
||||
| cursor | 光标位置 | _number_ | - |
|
||||
| keyCode | 键值 | _number_ | - |
|
||||
| callback | 调用该函数传 `{ value: string, cursor: number }` 来替换输入框的内容,具体用法可以参考 [wx-input](https://developers.weixin.qq.com/miniprogram/dev/component/input.html) | _function_ | - |
|
||||
| callback | 调用该函数传 `{ value: string, cursor: number }` 来替换输入框的内容,具体用法可以参考 [wx-input](https://developers.weixin.qq.com/miniprogram/dev/component/input.html) | _function_ | - |
|
||||
|
||||
### Slot
|
||||
|
||||
@ -319,8 +327,9 @@ Page({
|
||||
|
||||
### 外部样式类
|
||||
|
||||
| 类名 | 说明 |
|
||||
| ---------------- | -------------- |
|
||||
| label-class | 左侧文本样式类 |
|
||||
| input-class | 输入框样式类 |
|
||||
| right-icon-class | 右侧图标样式类 |
|
||||
| 类名 | 说明 |
|
||||
| ----------------------- | -------------- |
|
||||
| custom-class `v1.10.21` | 根节点样式类 |
|
||||
| label-class | 左侧文本样式类 |
|
||||
| input-class | 输入框样式类 |
|
||||
| right-icon-class | 右侧图标样式类 |
|
||||
|
@ -13,7 +13,7 @@
|
||||
title-style="margin-right: 12px;"
|
||||
custom-style="{{ customStyle }}"
|
||||
arrow-direction="{{ arrowDirection }}"
|
||||
custom-class="van-field"
|
||||
custom-class="custom-class van-field"
|
||||
>
|
||||
<slot name="left-icon" slot="icon" />
|
||||
<view wx:if="{{ label }}" class="label-class {{ utils.bem('field__label', { disabled }) }}" slot="title">
|
||||
|
@ -17,7 +17,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<van-field>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
@ -102,7 +102,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:click-icon="onClickIcon"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--required"
|
||||
@ -187,7 +187,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</van-field>
|
||||
<van-field>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--required van-cell--borderless"
|
||||
@ -278,7 +278,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<van-field>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
@ -379,7 +379,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<van-field>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell"
|
||||
@ -453,7 +453,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</van-field>
|
||||
<van-field>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
@ -551,7 +551,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<van-field>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell"
|
||||
@ -644,7 +644,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
rows="1"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
@ -738,7 +738,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
useButtonSlot="{{true}}"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--center van-cell--borderless"
|
||||
|
@ -32,7 +32,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:focus="onFocus"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
@ -142,7 +142,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:focus="onFocus"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
@ -260,7 +260,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:focus="onFocus"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
@ -366,7 +366,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:focus="onFocus"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
@ -472,7 +472,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:focus="onFocus"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
@ -585,7 +585,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
bind:focus="onFocus"
|
||||
>
|
||||
<van-cell
|
||||
customClass="van-field"
|
||||
customClass="custom-class van-field"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--borderless"
|
||||
|
Loading…
x
Reference in New Issue
Block a user