feat(Field): add name prop

This commit is contained in:
陈嘉涵 2020-02-07 14:33:44 +08:00
parent 03c826c4d4
commit 67bec61c6d
5 changed files with 23 additions and 2 deletions

View File

@ -214,8 +214,9 @@ Use `input-align` prop to align the input value
| Attribute | Description | Type | Default | | Attribute | Description | Type | Default |
|------|------|------|------| |------|------|------|------|
| value | Field value | *number \| string* | - | | v-model (value) | Field value | *number \| string* | - |
| label | Field label | *string* | - | | label | Field label | *string* | - |
| name | Name | *string* | - |
| type | Input type, can be set to `tel` `digit`<br>`number` `textarea` `password` | *string* | `text` | | type | Input type, can be set to `tel` `digit`<br>`number` `textarea` `password` | *string* | `text` |
| size | Sizecan be set to `large` | *string* | - | | size | Sizecan be set to `large` | *string* | - |
| maxlength | Max length of value | *number \| string* | - | | maxlength | Max length of value | *number \| string* | - |

View File

@ -233,8 +233,9 @@ export default {
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
|------|------|------|------| |------|------|------|------|
| v-model (value) | 当前输入的值 | *number \| string* | - |
| label | 输入框左侧文本 | *string* | - | | label | 输入框左侧文本 | *string* | - |
| value | 当前输入的值 | *number \| string* | - | | name | 名称,提交表单的标识符 | *string* | - |
| type | 输入框类型, 可选值为 `tel` `digit`<br>`number` `textarea` `password` 等 | *string* | `text` | | type | 输入框类型, 可选值为 `tel` `digit`<br>`number` `textarea` `password` 等 | *string* | `text` |
| size | 大小,可选值为 `large` | *string* | - | | size | 大小,可选值为 `large` | *string* | - |
| maxlength | 输入的最大字符数 | *number \| string* | - | | maxlength | 输入的最大字符数 | *number \| string* | - |

View File

@ -17,6 +17,7 @@ export default createComponent({
props: { props: {
...cellProps, ...cellProps,
name: String,
error: Boolean, error: Boolean,
disabled: Boolean, disabled: Boolean,
readonly: Boolean, readonly: Boolean,
@ -237,6 +238,7 @@ export default createComponent({
}, },
attrs: { attrs: {
...this.$attrs, ...this.$attrs,
name: this.name,
disabled: this.disabled, disabled: this.disabled,
readonly: this.readonly, readonly: this.readonly,
placeholder: this.placeholder, placeholder: this.placeholder,

View File

@ -53,6 +53,14 @@ exports[`label-width prop without unit 1`] = `
</div> </div>
`; `;
exports[`name prop 1`] = `
<div class="van-cell van-field">
<div class="van-cell__value van-cell__value--alone">
<div class="van-field__body"><input type="text" name="foo" class="van-field__control"></div>
</div>
</div>
`;
exports[`reach max word-limit 1`] = ` exports[`reach max word-limit 1`] = `
<div class="van-cell van-field"> <div class="van-cell van-field">
<div class="van-cell__value van-cell__value--alone"> <div class="van-cell__value van-cell__value--alone">

View File

@ -291,3 +291,12 @@ test('reach max word-limit', () => {
}); });
expect(wrapper).toMatchSnapshot(); expect(wrapper).toMatchSnapshot();
}); });
test('name prop', () => {
const wrapper = mount(Field, {
propsData: {
name: 'foo',
},
});
expect(wrapper).toMatchSnapshot();
});