1👍
Thats not valid. created()
is a own hook of vue and should be outside of methods
.
const app = new Vue({
el: "#app",
data: {
errors: [],
name: null,
age: null
},
methods: {
checkForm: function(e) {
if (this.name && this.age) {
console.log(this.name);
return true;
}
console.log(this.name);
this.errors = [];
if (!this.name) {
this.errors.push("Name required.");
}
if (!this.age) {
this.errors.push("Age required.");
}
e.preventDefault();
}
},
async created() {
console.log("instance created");
}
});
- [Vuejs]-Dynamic components won't render corresponding templates
- [Vuejs]-Vue – How to search filter specific part in data?
Source:stackexchange.com