I'm new to vue,
So, to describe my work:
I implemented a form and bound it to the data() hooks to retrieve the data from the from, and then onSubmit() I create an object newClass{} and $emit it to parent component and to be manipulated later.
It works fine, but on the console I get error regarding my newly created object newClass{} saying Property '<object-property>' does not exist on type <component-name>.
Below, here's my code :
@Component
export default class Form extends Vue {
//Bind form data
data() {
return {
id: "",
name: "",
age: 0,
amountA: 0,
amountB: 0,
capitalA: 0,
capitalB: 0
}
}
onSubmit(e: any): void {
e.preventDefault();
//Create newClass object
const newClass = {
id: this.id,
name: this.name,
age: this.age,
amountA: this.amountA,
amountB: this.amountB,
capitalA: this.capitalA,
capitalB: this.capitalB
}
//Emit the class to parent component
this.$emit("add-class", newClass);
this.$emit("update");
//Reset Form
this.id = ""
this.name = ""
this.age = 0
this.amountA = 0
this.amountB = 0
this.capitalB = 0
this.capitalB = 0
}
Here's the output of the error I get :
And same case for the form rest part, I also get the errors for every property of my newClass object.
Thanks in advance!