新聞中心
這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)vue中怎么實現(xiàn)一個自動化表單,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

通過json配置快速生成表單的vue plugin。
設(shè)計目標(biāo)
減少html 重復(fù)片段
表單字段組件可擴(kuò)展
事件、聯(lián)動通過eventbus 解耦
校驗可擴(kuò)展
表單布局可自定義
可視化配置
大概方案設(shè)計

使用
安裝
npm install charlie-autoform charlie-autoform_component_lib
源碼:https://charlielau.github.io/autoform/#/component/autoform
引入插件
import AutoForm from 'charlie-autoform'; import AutoForm_component_lib from 'charlie-autoform_component_lib'; Vue.use(AutoForm); Vue.use(AutoForm_component_lib);
基本使用
demo.vue
立即創(chuàng)建 取消
最終效果

添加自定義組件或者組件目錄
Vue.$autoform.RegisterDir(()=>require.context('./components/autoform', 'c'));//目錄
Vue.$autoform.Register(Vue,[Components...],{prefix: "c"}) //組件對象cHello.vue
// PATH:/components/autoform/cHello.vue基本的變量可以通過"mixins"獲取,這里有開發(fā)組件需要的一些變量
自定義子組件:Hello
當(dāng)前field: {{field}}
整個model: {{model}}
當(dāng)前model: {{model[field.name]}}
layout: {{layout}}
字段相關(guān)配置to: {{to}}
上述就是小編為大家分享的vue中怎么實現(xiàn)一個自動化表單了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)頁題目:vue中怎么實現(xiàn)一個自動化表單-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://www.dlmjj.cn/article/djedee.html


咨詢
建站咨詢
