Javascript 使用网页包Encore Symfony 4未找到Alertify
我在项目中使用Alertify时遇到了麻烦。我正在使用symfony 4的网页安可 我已通过以下方式获得信息: npm安装alertifyjs--保存 这是我的app.jsJavascript 使用网页包Encore Symfony 4未找到Alertify,javascript,webpack,symfony4,webpack-encore,alertifyjs,Javascript,Webpack,Symfony4,Webpack Encore,Alertifyjs,我在项目中使用Alertify时遇到了麻烦。我正在使用symfony 4的网页安可 我已通过以下方式获得信息: npm安装alertifyjs--保存 这是我的app.js // any CSS you require will output into a single css file (app.css in this case) import '../css/app.css'; import '../../node_modules/bootstrap/dist/css/bootstr
// any CSS you require will output into a single css file (app.css in this case)
import '../css/app.css';
import '../../node_modules/bootstrap/dist/css/bootstrap.css';
import '../../node_modules/admin-lte/bower_components/font-awesome/css/font-awesome.min.css';
import '../../node_modules/admin-lte/bower_components/Ionicons/css/ionicons.min.css';
import '../../node_modules/admin-lte/dist/css/AdminLTE.min.css';
import '../../node_modules/admin-lte/dist/css/skins/skin-blue.min.css';
const $ = require('jquery');
global.$ = global.jquery = $;
import 'bootstrap';
import '../../node_modules/admin-lte/bower_components/jquery-ui/jquery-ui.js';
import '../../node_modules/admin-lte/dist/js/adminlte.js';
const alertify = require('alertifyjs');
global.alertify = alertify;
// Custom js
import './dashboard/GMDashboard.js';
import './explotations/GMExplotations.js';
在我尝试使用的对象上,您可以看到我正在将window、jQuery和alertify传递给闭包,以便在内部使用它们,但我得到了以下错误:
GMExplotations.js:37未捕获引用错误:未定义alertify
反对。(GMExplotations.js:37)
位于Object../assets/js/explotations/GMExplotations.js(app.js:327)
在网页上需要(引导:78)
在模块上。(app.js:1)
位于模块../assets/js/app.js(app.js:23)
在网页上需要(引导:78)
在CheckDeferredModule(引导:45)
自动引导时:151
自动引导时:151
“严格使用”;
(功能(窗口,$,警报){
window.GMExplotations=函数($wrapper){
log($wrapper);
这个。$wrapper=$wrapper;
//TODO:绑定事件
//应用初始化
this.init();
};
$.extend(window.GMExplotations.prototype{
_选择器:{
},
init:function(){
console.log('Alertify test');
警觉
.alert(“这是一个警报对话框。”,函数(){
alertify.message('OK');
});
},
});
让ExplorationsWrapper=$(“#Explorations表”);
如果(ExplotationsWrapper.length>0){
设GM=新的GMExplotations(ExplotationsWrapper);
}
})(窗口、jQuery、alertify);
'use strict';
(function(window, $, alertify) {
window.GMExplotations = function($wrapper) {
console.log($wrapper);
this.$wrapper = $wrapper;
//TODO: Bind events
// App Init
this.init();
};
$.extend(window.GMExplotations.prototype, {
_selectors: {
},
init: function() {
console.log('Alertify test');
alertify
.alert("This is an alert dialog.", function(){
alertify.message('OK');
});
},
});
let ExplotationsWrapper = $('#explotations-table');
if (ExplotationsWrapper.length > 0) {
let GM = new GMExplotations(ExplotationsWrapper);
}
})(window, jQuery, alertify); <- Here fails