I have a form.js stored in my resource/js/
class Form{
constructor(){
//more coding here
}
//more coding here
}
My question is how can I import the file above inside my .vue file? I tried these below:
<template>
//some html here
</template>
<script src="../form.js"></script>
<script>
export default{
data(){
return {
form: new Form({
title: '',
body: ''
})
}
}
}
</script>
But still getting these error:
[Vue warn]: Error in data(): "ReferenceError: Form is not defined"
PROBLEM SOLVED:
export default class Form{
//more coding here
}
import Form from '../form.js';
import Form from '../form.js';from that link but returns me an error [Vue warn]: Error in data(): "TypeError: form_js_WEBPACK_IMPORTED_MODULE_0___default.a is not a constructor"export defaultin form.js?export default class Form { ... }Errors?