el-form-item
时间: 2023-11-05 19:27:25 浏览: 94
El-form-item is a component in the Element UI library for Vue.js. It is used as a wrapper for form inputs to provide validation, error messages, and label display. It can be used in conjunction with the el-form component to create forms in Vue.js applications. The el-form-item component provides a set of props and events that allow developers to customize its behavior and appearance. Some of the props include label, prop, rules, and inline, while some of the events include validate and blur. Overall, el-form-item is a useful component in building robust and user-friendly forms in Vue.js applications.
相关问题
el-form-item内 循环el-form-item el-form-item输入内容了,但是失去叫焦点为什么会校验
el-form-item内循环el-form-item时,如果输入内容后失去焦点,仍然会进行校验的原因是因为el-form-item内部的el-form-item会继承父级el-form-item的校验规则。所以即使子级el-form-item输入了内容,但是失去焦点后,父级el-form-item仍然会进行校验。
为了解决这个问题,可以在子级el-form-item上添加`prop`属性,并将其设置为一个唯一的值,以避免继承父级校验规则。例如:
```html
<el-form-item prop="childFormItem">
<el-form-item>
<el-input v-model="inputValue"></el-input>
</el-form-item>
</el-form-item>
```
这样,子级el-form-item就会独立进行校验,不会受到父级el-form-item的影响。
<el-form label-position="left"> <el-row> <el-col :span="4"> <el-form-item label="姓名"> <el-input></el-input> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="年龄"> <el-input></el-input> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="性别"> <el-radio-group> <el-radio label="male">男</el-radio> <el-radio label="female">女</el-radio> </el-radio-group> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="12"> <el-form-item label="地址"> <el-input></el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="邮箱"> <el-input></el-input> </el-form-item> </el-col> </el-row> </el-form> 如何使表单的标签显示在左侧
可以通过设置 `label-position` 属性为 "left" 来使表单的标签显示在左侧,具体代码如下:
```html
<el-form label-position="left">
<!-- 表单内容 -->
</el-form>
```
这样表单中每个表单项的标签都会显示在左侧。
阅读全文