I'm attempting to incorporate a JS file
into the Vuejs script
but for some reason, it's not working as expected.
JS file
class Errors {
constructor() {
this.errors = {};
}
get(field) {
if (_.has(this.errors, 'errors.' + field)) {
return this.errors['errors'][field][0];
}
}
}
module.export = {
Errors: Errors
}
Vuejs file
<script>
var { Errors } = require('../../classes');
export default {
data() {
return {
errors: new Errors
}
}
}
Console errors
[Vue warn]: Error in data(): "TypeError: Errors is not a constructor"
TypeError: Errors is not a constructor
Question
What is the correct way to include the JS file
in the Vuejs script
?
Is there a way to achieve this, or are there any simple alternatives available?
Thank you.