you have to use import. Also, I'm not sure if you can import in a blade as I've never tried it; I always am using external scripts for everything, that way everything can be in laravel mix.
import Person from './path/to/person.js;
Is there a requirement that I'm missing to have ES6 classes available for use in the view? If I declare the following in public/js/person.js:
Class Person {
constructor(data){
name = data.name;
}
}
export default Person;
Then somewhere in my mix file I have:
mix.babel(['public/js/person.js'],'public/js/person.min.js');
Then in the view:
<script src="{{ mix('js/person.min.js') }}"></script>
<script>var bob = new Person({name: "Bob"});</script>
I get the error:
Uncaught ReferenceError: Person is not defined
Am I missing something? L5.4 [email protected]
I did get it to work by:
Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function t(t,i)....
window.bob = new Person({name: "Bob"});
Not sure why as this is my first use of ES6 classes.
Please or to participate in this conversation.