el-form-schema的數(shù)據(jù)結(jié)構(gòu)設(shè)計(jì)

歡迎使用

https://github.com/China-Wesley/el-form-schema

<el-form-schema
  ref="form"
  :schema="schema"
  :model="model"
  cancel-button
  submit-button
  reset-button
  :layout="layout"
  @cancel="cancelHand"
  @submit="submitHand"
  @reset="resetHand"
  @validate="handleFunc"
  @add="addFunc"
  @remove="removeFunc"
></el-form-schema> 
model = {
   // 映射到schema的items的結(jié)構(gòu)中去
}
schema = {
     title: "", // 是整個(gè)form的標(biāo)題
     border: true,
     config: {},  // 可以配置整個(gè)表單
     buttonConfig: {
          common: {},
          cancelButton: {},
          submitButton: {},
          resetButton: {}
     },
     visible: true,
     items: {  // items是獨(dú)一無(wú)二的
          [prop]: {
               label: '', //item的label
               type: 'number' || 'array' || 'object', // 這里是傳值的類(lèi)型
               component: '' || Function || {render: () => {}}, //這個(gè)可以傳入自定義組件,或者固定的值如 input、select、colorPicker等
               disabled: true,
               visible: true,
               events: {}, // 傳入component item的事件
               field: {
                    option, // [{label: "", value: 1}] // option要保持這種格式
                    ...elementFieldSet, // element自帶的表單設(shè)置
                    inner: ""  || Component || {render: () => {}} // slot非具名的
                    // 實(shí)際上就是傳入component的配置,即form-item的各種屬性
               },
               rules: [], // 這里面全部都是驗(yàn)證規(guī)則,應(yīng)該和el-form保持一致
               config: {}, //單個(gè)item應(yīng)該有單獨(dú)的config
               children: {},
               dynamicProps: {}, // 當(dāng)傳入的是動(dòng)態(tài)組件時(shí),這個(gè)作為動(dòng)態(tài)組件的prop傳入其中
               slot: {
                    tip: "" || {render: () => {}}
               }, // 可以循環(huán)嵌套的slot
               addable: true, // type = 'array' 時(shí) 增加和刪除按鈕,默認(rèn)為true
               removeAble: true,
               addButton: {}, // 按鈕的配置
               removeButton: {},
               items: {}// 可嵌套的 當(dāng)type='array' || type='object'時(shí)使用,映射model的結(jié)構(gòu)
           }
     }
}
layout = [{
     title: "", //一行的title
     rowAttrs: {}, // el-row的一些配置
     col: [
          {
               colAttrs: {}, // el-col的一些配置
               fields: [""], // 只能填schema一級(jí)的items
               title: "" // 列標(biāo)題
          },
          
     ]
}]
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容