Skip to content

Commit

Permalink
feat(Field): add name prop
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Feb 7, 2020
1 parent 0f13785 commit f3398dc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/field/README.md
Expand Up @@ -214,8 +214,9 @@ Use `input-align` prop to align the input value

| Attribute | Description | Type | Default |
|------|------|------|------|
| value | Field value | *number \| string* | - |
| v-model (value) | Field value | *number \| string* | - |
| label | Field label | *string* | - |
| name | Name | *string* | - |
| type | Input type, can be set to `tel` `digit`<br>`number` `textarea` `password` | *string* | `text` |
| size | Size,can be set to `large` | *string* | - |
| maxlength | Max length of value | *number \| string* | - |
Expand Down
3 changes: 2 additions & 1 deletion src/field/README.zh-CN.md
Expand Up @@ -233,8 +233,9 @@ export default {

| 参数 | 说明 | 类型 | 默认值 |
|------|------|------|------|
| v-model (value) | 当前输入的值 | *number \| string* | - |
| label | 输入框左侧文本 | *string* | - |
| value | 当前输入的值 | *number \| string* | - |
| name | 名称,提交表单的标识符 | *string* | - |
| type | 输入框类型, 可选值为 `tel` `digit`<br>`number` `textarea` `password`| *string* | `text` |
| size | 大小,可选值为 `large` | *string* | - |
| maxlength | 输入的最大字符数 | *number \| string* | - |
Expand Down
2 changes: 2 additions & 0 deletions src/field/index.js
Expand Up @@ -17,6 +17,7 @@ export default createComponent({

props: {
...cellProps,
name: String,
error: Boolean,
disabled: Boolean,
readonly: Boolean,
Expand Down Expand Up @@ -237,6 +238,7 @@ export default createComponent({
},
attrs: {
...this.$attrs,
name: this.name,
disabled: this.disabled,
readonly: this.readonly,
placeholder: this.placeholder,
Expand Down
8 changes: 8 additions & 0 deletions src/field/test/__snapshots__/index.spec.js.snap
Expand Up @@ -53,6 +53,14 @@ exports[`label-width prop without unit 1`] = `
</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`] = `
<div class="van-cell van-field">
<div class="van-cell__value van-cell__value--alone">
Expand Down
9 changes: 9 additions & 0 deletions src/field/test/index.spec.js
Expand Up @@ -291,3 +291,12 @@ test('reach max word-limit', () => {
});
expect(wrapper).toMatchSnapshot();
});

test('name prop', () => {
const wrapper = mount(Field, {
propsData: {
name: 'foo',
},
});
expect(wrapper).toMatchSnapshot();
});

0 comments on commit f3398dc

Please sign in to comment.