2018-05-06 18:32:40 +08:00
|
|
|
<cn>
|
|
|
|
#### 表单布局
|
|
|
|
表单有三种布局。
|
|
|
|
</cn>
|
|
|
|
|
|
|
|
<us>
|
|
|
|
#### Form Layout
|
|
|
|
There are three layout for form: `horizontal`, `vertical`, `inline`.
|
|
|
|
</us>
|
|
|
|
|
2018-05-08 11:20:07 +08:00
|
|
|
|
2018-05-06 18:32:40 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<a-form :layout="formLayout">
|
|
|
|
<a-form-item
|
|
|
|
label='Form Layout'
|
|
|
|
:labelCol="formItemLayout.labelCol"
|
|
|
|
:wrapperCol="formItemLayout.wrapperCol"
|
|
|
|
>
|
|
|
|
<a-radio-group defaultValue='horizontal' @change="handleFormLayoutChange">
|
|
|
|
<a-radio-button value='horizontal'>Horizontal</a-radio-button>
|
|
|
|
<a-radio-button value='vertical'>Vertical</a-radio-button>
|
|
|
|
<a-radio-button value='inline'>Inline</a-radio-button>
|
|
|
|
</a-radio-group>
|
|
|
|
</a-form-item>
|
|
|
|
<a-form-item
|
|
|
|
label='Field A'
|
|
|
|
:labelCol="formItemLayout.labelCol"
|
|
|
|
:wrapperCol="formItemLayout.wrapperCol"
|
|
|
|
>
|
|
|
|
<a-input placeholder='input placeholder' />
|
|
|
|
</a-form-item>
|
|
|
|
<a-form-item
|
|
|
|
label='Field B'
|
|
|
|
:labelCol="formItemLayout.labelCol"
|
|
|
|
:wrapperCol="formItemLayout.wrapperCol"
|
|
|
|
>
|
|
|
|
<a-input placeholder='input placeholder' />
|
|
|
|
</a-form-item>
|
|
|
|
<a-form-item
|
|
|
|
:wrapperCol="buttonItemLayout.wrapperCol"
|
|
|
|
>
|
|
|
|
<a-button type='primary'>Submit</a-button>
|
|
|
|
</a-form-item>
|
|
|
|
</a-form>
|
2018-05-08 11:20:07 +08:00
|
|
|
</div>
|
2018-05-06 18:32:40 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
formLayout: 'horizontal',
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
2018-05-06 18:32:40 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleFormLayoutChange (e) {
|
2019-01-12 11:33:27 +08:00
|
|
|
this.formLayout = e.target.value;
|
2018-05-06 18:32:40 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
formItemLayout () {
|
2019-01-12 11:33:27 +08:00
|
|
|
const { formLayout } = this;
|
2018-05-06 18:32:40 +08:00
|
|
|
return formLayout === 'horizontal' ? {
|
|
|
|
labelCol: { span: 4 },
|
|
|
|
wrapperCol: { span: 14 },
|
2019-01-12 11:33:27 +08:00
|
|
|
} : {};
|
2018-05-06 18:32:40 +08:00
|
|
|
},
|
|
|
|
buttonItemLayout () {
|
2019-01-12 11:33:27 +08:00
|
|
|
const { formLayout } = this;
|
2018-05-06 18:32:40 +08:00
|
|
|
return formLayout === 'horizontal' ? {
|
|
|
|
wrapperCol: { span: 14, offset: 4 },
|
2019-01-12 11:33:27 +08:00
|
|
|
} : {};
|
2018-05-06 18:32:40 +08:00
|
|
|
},
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
2018-05-06 18:32:40 +08:00
|
|
|
</script>
|
2018-05-08 11:20:07 +08:00
|
|
|
|
2018-05-06 18:32:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
|