将jquery与Angular 4结合使用
我想显示一个引导模式,但我仍然得到将jquery与Angular 4结合使用,jquery,angular,typescript,bootstrap-4,Jquery,Angular,Typescript,Bootstrap 4,我想显示一个引导模式,但我仍然得到 SectionDetailComponent.html:54 ERROR TypeError: $(...).modal is not a function My.cli: "scripts": [ "../node_modules/jquery/dist/jquery.min.js", "../node_modules/bootstrap/dist/js/bootstrap.min.js" ], 我的组成部分: declare var
SectionDetailComponent.html:54 ERROR TypeError: $(...).modal is not a function
My.cli:
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
我的组成部分:
declare var jquery:any;
declare var $:any;
已解决:
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
您应该尝试使用ngx bootstrap或ng bootstrap来使用bootstrap 4,而不是使用常规的bootstrap.js。它是专门为Angular 4设计的谢谢你的回答,我真正的问题是Popper.js,我只需要在jquery之后和Bootstrap之前添加内部脚本。与Bootstrap+jquery相比,ng Bootstrap或ngx Bootstrap的通用版本在Angular上工作得更好、更自然。注意:我没有在这里否决任何东西。老实说,甚至没有必要将jquery与angular一起使用。Angular的内置libs可以完成jquery所做的一切。