formulate el ui
1.0.0

本專案為vueformulate專案加上了element-ui皮膚,可以讓你在element-ui專案中使用vueformulate時保持風格統一
關於element-ui 中的
el-form和vueformulate套件的功能比較,我寫了一篇文章,供大家參考借鑒
本項目遵循語意化版本2.0
yarn add formulate-el-ui
點擊預覽
在你的main.js檔案的適當位置加上以下程式碼:
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 的风格
})
如果需要使用行內表單(所有的表單欄位在一行內顯示),則可以在FormulateForm元件上加一個el-formulate__form-inline樣式即可:
<FormulateForm
:form-class="['el-formulate__form-inline']"
>
<FormulateInput
label="个性签名"
type="el-input"
value="你好,Element-UI"
/>
</FormulateForm>
要了解更多,請訪問
form-class的文檔
注意:使用行內表單時,展示錯誤訊息使用了
position:absoulte, 如果欄位中的驗證規則有多條錯誤訊息,會導致展示錯亂,所以,需要在驗證中使用bail規則, 這樣錯誤訊息就會只展示一條。
import {
CheckboxHelp,
} from 'formulate-el-ui'
Vue.use(VueFormulate, {
plugins: [CheckboxHelp], // CheckboxHelp 用于解决 checkbox 组件中 help 信息展示位置错误的问题
})
包含的規則:
import {
rules,
} from 'formulate-el-ui'
Vue.use(VueFormulate, {
plugins: [rules],
})
import {
inputs,
} from 'formulate-el-ui'
Vue.use(VueFormulate, {
plugins: [inputs],
})
目前包含的組件
| 組件 | FormulateInput type | 支援的prop |
|---|---|---|
| Input | el-input | autosize, clearable, maxlength, minlength,rows, disabled showPassword, showWordLimit, elType (值為 textarea時,是多行文字方塊) |
| Cascader | el-cascader | beforeFilter, clearable, collapseTags, debounce, disabled, filterMethod, elLabel, options, placeholder, popperClass, props, separator, showAllLevels, size, elValue |
| ColorPicker 顏色選擇器 | 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 |
element-ui 的el-form-item元件,當加上了required prop 後,會顯示一個紅色*提示用戶該字段必填,現在本項目也已支持,只要是FormulateInput的驗證規則中包含required ,則會預設加上這個紅色* ,如果不想顯示,可以在FormulateInput上設定requiredTip prop 為false ,即可:
<FormulateInput :required-tip="false" />
formulate-form元件上加上一個v-if="loadForm" loadForm預設值設定為false ,待介面回傳資料後,然後再置位true , 即可達到渲染圖片的目的查看vueformulate 文檔
MIT
已推出輔助開發的vscode 插件,可以點選formulate-el-helper 安裝
如果你感覺好用,就給項目打個星星吧^_^