我正在尝试通过在刀片中创建实例来从JS文件访问类。
有没有办法在js文件之外访问它?
Formula.js
class Formula() {
initialize() {
...
}
}
App.js
require('./modules/formulas/Formula');
formula.blade.php
@section('page-specific-js')
<script>
var Formula = new Formula();
Formula.initialize();
</script>
@endsection
Webpack.mix.js
mix.js('resources/assets/js/app.js', 'public/js')
.extract(['jquery', 'bootstrap-sass', 'moment', 'datatables-bootstrap', 'vue', 'axios']);
错误
Uncaught TypeError: Formula is not a constructor