Skip to content

Improve the field loading method #244

Closed
@lionel-bijaoui

Description

@lionel-bijaoui

This is a following to the discussion started in #232

The goal is to make field loading more modular, so that you only use the fields you really need.
@cristijora proposed this solution:

adding component names exporting fields in a separate file

//input field

export default{
name:'vfgFieldInput'
}

//fields index file

export default {Input, Checkbox} etc 
install(Vue,options) {
     Vue.component("VueFormGenerator", module.exports.component);
     if(option.fields){
       fields.forEach((field)=>{
         Vue.component(field.name,field);
       })
     }
}

Usage:

import VFG from 'vue-form-generator'
import {Input, Checkbox, AutoComplete} from 'vue-form-generator/fields'
Vue.use(VFG, [Input,Checkbox,Autocomplete])

This solution is a sweet spot between one big pack and only modular field. It allow to use internal component and custom ones, and take advantages of webpack tree-shaking feature.

Now, this also add some change to the plugin and some create some problem that we need to fix for v3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions