This project adds element-ui
skin to the vueformulate
project, which allows you to maintain a unified style when using vueformulate
in element-ui
projects.
Regarding the functional comparison between
el-form
andvueformulate
packages in element-ui, I wrote an article for your reference.
This project follows Semantic Version 2.0
yarn add formulate-el-ui
Click to preview
Add the following code to the appropriate location in your main.js
file:
import 'formulate-el-ui/dist/element-ui.min.css';
import formulateElementUI from 'formulate-el-ui'
Vue.use(VueFormulate, {
plugins: [formulateElementUI]
})
import {
theme
} from 'formulate-el-ui'
import 'formulate-el-ui/dist/element-ui.min.css';
Vue.use(VueFormulate, {
plugins: [theme], // 配合上面引入的样式文件,使用 element-ui 的风格
})
If you need to use an inline form (all form fields are displayed in one line), you can add an el-formulate__form-inline
style to the FormulateForm
component:
<FormulateForm
:form-class="['el-formulate__form-inline']"
>
<FormulateInput
label="个性签名"
type="el-input"
value="你好,Element-UI"
/>
</FormulateForm>
To learn more, visit the documentation for
form-class
Note: When using an inline form,
position:absoulte
is used to display error messages. If there are multiple error messages in the validation rules in the field, the display will be confusing. Therefore, you need to use thebail
rule in the validation, so that only the error messages will be displayed. One piece.
import {
CheckboxHelp,
} from 'formulate-el-ui'
Vue.use(VueFormulate, {
plugins: [CheckboxHelp], // CheckboxHelp 用于解决 checkbox 组件中 help 信息展示位置错误的问题
})
Rules included:
import {
rules,
} from 'formulate-el-ui'
Vue.use(VueFormulate, {
plugins: [rules],
})
import {
inputs,
} from 'formulate-el-ui'
Vue.use(VueFormulate, {
plugins: [inputs],
})
Currently included components
components | FormulateInput type | Supported props |
---|---|---|
Input | el-input | autosize, clearable, maxlength, minlength, rows, disabled showPassword, showWordLimit, elType (when the value is textarea , it is a multi-line text box) |
Cascader | el-cascader | beforeFilter, clearable, collapseTags, debounce, disabled, filterMethod, elLabel, options, placeholder, popperClass, props, separator, showAllLevels, size, elValue |
ColorPicker color picker | el-color-picker | colorFormat,predefine,showAlpha |
InputNumber | el-input-number | min,max,step,stepStrictly,precision,disabled |
Rate | el-rate | allowHalf,colors,disabledVoidColor,disabledVoidIconClass ,highThreshold,iconClasses,max,lowThreshold,showScore,showText, texts,testColor,voidColor,voidIconClass |
Select | el-select | allowCreate, clearable, collapseTags, filterable, disabled, multiple |
Slider | el-slider | formatTooltip,min,marks,max,scoreTemplate, showTooltip,step,showStops,showInput,showInputControls, range,vertical,height |
Switch | el-switch | activeText,inactiveText,activeColor,inactiveColor, disabled |
When required
prop is added to the el-form-item
component of element-ui, a red *
will be displayed to remind the user that this field is required. Now this project also supports it. As long as the validation rule of FormulateInput
contains required
, it will This red *
is added by default. If you don't want to display it, you can set requiredTip
prop to false
on FormulateInput
, that's it:
<FormulateInput :required-tip="false" />
v-if="loadForm"
on the formulate-form
component. v-if="loadForm"
The default value of loadForm
is set to false
. After the interface returns the data, then set it to true
to achieve the purpose of rendering the image. View vueformulate documentation
MIT
A vscode plug-in to assist development has been launched. You can click formulate-el-helper to install it.
If you find it useful, give the project a star^_^