gpt4 book ai didi

javascript - Symfony:Webpack Encore Require()无法正常工作吗?

转载 作者:行者123 更新时间:2023-11-28 03:52:31 25 4
gpt4 key购买 nike

我尝试使用Symfony Webpack Encore。这是我的默认控制器树枝中包含的app.js。我不能使用BootstrapDialog。

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 list -g --depth = 0

/usr/local/Cellar/node/9.3.0_1/lib
├── bootstrap@3.3.7
├── bootstrap3-dialog@1.35.4
├── jquery@3.2.1
└── npm@5.6.0

最佳答案

你有没有尝试过

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


如果要在 app.js之外使用它,则可能需要另外添加类似内容

window.BootstrapDialog = BootstrapDialog;

关于javascript - Symfony:Webpack Encore Require()无法正常工作吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47866011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com