Extension of Vue
Extension of Vue
forms
object
The By default, vue-formily will inject an object called forms
to current Vue instance, which is holding all the Form instances. The forms
alias can be customized by setting the alias
option in the installation step.
To imagine that, let's see the example below:
// Install vue-formily
import VueFormily from 'vue-formily';
Vue.use(VueFormily);
// In Vue component
export default {
created() {
this.$formily.addForm({
formId: 'login',
// ...
});
},
methods: {
async submit() {
// Access the login form through the `forms` object
await this.forms.login.validate();
}
}
}
$formily
Instance
The Every Vue instance will have a $formily instance which contains the following methods:
addForm
Create new Form instance and injects it to forms
object of the current Vue instance, and vue-formily will auto bind the current Vue instanceto the form.
Signatures
addForm(schema: FormSchema): Form;
Parameters
- schema - The FormSchema.
Returns
- The Form instance.
removeForm
Remove a form element.
Signatures
removeForm(formId: string): void;
Parameters
- formId - The form id.
getForm
Get a form element.
Signatures
getForm(formId: string): Form;
Parameters
- formId - The form id.