2017-12-18 27 views
1

我嘗試使用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] 

回答

0

你試過

var BootstrapDialog = require('bootstrap-dialog'); 

如果你想在室外使用app.js ,您可能需要額外添加mething like

window.BootstrapDialog = BootstrapDialog; 
相關問題