无法使引导多选(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之前,但它却将其放在相反的位置。
发布于 2018-09-05 20:11:21
这可能确实是一个webpack的问题。在我的经验中,以某种方式打包的包总是更容易使用,以便供angular使用。
有一个名为angular2dropdown-multiselect的包。
您是否可以选择使用此软件包,或者对您的用例来说,引导多选是一个硬性要求吗?
https://stackoverflow.com/questions/52184600
复制相似问题