还需要设置表单宽度
时间: 2023-10-08 16:05:13 浏览: 83
是的,可以将 `el-form` 组件的样式设置为:
```html
<el-form :model="user" status-icon :rules="rules" ref="ruleForm" class="demo-ruleForm" style="width: 100%;">
```
这样,表单的宽度就会占满父元素的宽度。完整代码如下:
```html
<div style="display: flex; justify-content: center; align-items: center; width: 700px; margin: 0 auto;">
<el-form :model="user" status-icon :rules="rules" ref="ruleForm" class="demo-ruleForm" style="width: 100%;">
<el-form-item label="密码" prop="username" width="250px">
<el-input type="password" v-model="user.pass" autocomplete="off" width="250px"></el-input>
</el-form-item>
<el-form-item label="确认密码" prop="password" width="250px">
<el-input type="password" v-model="user.checkPass" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="身份" prop="rank" width="250px">
<el-select v-model="user.rank" placeholder="请选择">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="resetForm">重置</el-button>
</el-form-item>
</el-form>
</div>
```
阅读全文