0👍
You could use typescript type casting and do something like
interface VueFormField extends Vue {
validate: () => any
}
validate() {
this.form.formFields.forEach((field) => {
let key = "";
if (field.configuration) {
key = field.configuration.key;
}
console.log((this.$refs[key] as VueFormField).validate());
});
}
You could also use the dynamic component vue feature to get a more elegant solution generating your forms, also using template refs like this
- [Vuejs]-Bound function gets called multiple times over different components
- [Vuejs]-Getting an error TypeError: Cannot read properties of undefined (reading 'state') in vuejs while using Vuex
Source:stackexchange.com