Symfony:Webpack Encore Require()不工作?
我尝试使用Symfony Webpack Encore。这是我的默认控制器树枝中包含的app.js。我不能使用BootstrapDialog。Symfony:Webpack Encore Require()不工作?
require("bootstrap"); require("bootstrap-dialog");
console.log("Hello");
$(function() {
console.log('Hello with jquery');
});
BootstrapDialog.alert('Hello from dialog');
输出:
app.js:6 Hello iam a asset 10:47:34.793 app.js:13 Uncaught ReferenceError: BootstrapDialog is not defined
at Object.<anonymous> (app.js:13)
at Object../app/Resources/public/js/app.js (app.js:28)
at __webpack_require__ (bootstrap 51bba752688cd28a7b76:54)
at webpackJsonpCallback (bootstrap 51bba752688cd28a7b76:25)
at app.js:1
(anonymous) @ app.js:13
./app/Resources/public/js/app.js @ app.js:28
__webpack_require__ @ bootstrap 51bba752688cd28a7b76:54
webpackJsonpCallback @ bootstrap 51bba752688cd28a7b76:25
(anonymous) @ app.js:1
10:47:34.810 app.js:9 Hello with jquery
NPM列表-g --depth = 0
/usr/local/Cellar/node/9.3.0_1/lib ├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
回答:
你试过
var BootstrapDialog = require('bootstrap-dialog');
如果你想在室外使用app.js
,您可能需要额外添加mething like
window.BootstrapDialog = BootstrapDialog;
以上是 Symfony:Webpack Encore Require()不工作? 的全部内容, 来源链接: utcz.com/qa/262322.html