gpt4 book ai didi

angular - 让 bootstrap-multiselect 与 Angular 2+ 一起工作

转载 作者:搜寻专家 更新时间:2023-10-30 21:57:32 24 4
gpt4 key购买 nike

无法让 bootstrap-multiselect ( http://davidstutz.de/bootstrap-multiselect ) 与 Angular2+ 一起工作。据我所知,一切都已正确安装:

packages.json:

"dependencies": {
(...)
"bootstrap": "^4.1.3",
"bootstrap-multiselect": "^0.9.13-1",
"jquery": "^3.3.1",
}

angular.json:

"styles": [
"./node_modules/bootstrap/scss/bootstrap.scss",
"./node_modules/bootstrap-multiselect/dist/css/bootstrap-multiselect.css",
"src/styles.css"
],
"scripts": [
"./node_modules/jquery/dist/jquery.js",
"./node_modules/bootstrap/dist/js/bootstrap.js",
"./node_modules/bootstrap-multiselect/dist/js/bootstrap-multiselect.js",
]

但是当我在浏览器中加载应用程序时出现错误:

TypeError: $ is undefined
./node_modules/bootstrap-multiselect/dist/js/bootstrap-multiselect.js/<
bootstrap-multiselect.js:1388
./node_modules/bootstrap-multiselect/dist/js/bootstrap-multiselect.js
bootstrap-multiselect.js:44
__webpack_require__
./src/app/tasks/tasks.component.ts
__webpack_require__
./src/app/app.module.ts
__webpack_require__
./src/main.ts
__webpack_require__
[0]
__webpack_require__
checkDeferredModules
webpackJsonpCallback

我的猜测是 webpack 使用脚本以错误的顺序创建包。它应该将 jQuery 置于 bootstrap-multiselect 之前,但它却将其置于相反的位置。

最佳答案

这确实可能是 webpack 的问题。根据我的经验,使用以某种方式打包的包总是更容易,以便它可以被 angular 使用。

有一个包叫angular2dropdown-multiselect .

您是否可以选择使用此软件包,或者 bootstrap-multiselect 是否是您用例的硬性要求?

关于angular - 让 bootstrap-multiselect 与 Angular 2+ 一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52184600/

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