加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在角度2中使用bootstrap组件

发布时间:2020-12-17 21:22:56 所属栏目:安全 来源:网络整理
导读:Angular 2 cli可以添加bootstrap js组件并在项目组件中使用它们. 虽然还有其他的bootstrap库,如ng-bootstrap专为angular 2而构建. 我想知道两种方法之间有什么区别,可以通过简单的npm install bootstrap在angular 2中使用bootstrap组件,并在angular-cli.json
Angular 2 cli可以添加bootstrap js组件并在项目组件中使用它们.

虽然还有其他的bootstrap库,如ng-bootstrap专为angular 2而构建.

我想知道两种方法之间有什么区别,可以通过简单的npm install bootstrap在angular 2中使用bootstrap组件,并在angular-cli.json的app脚本中包含它

解决方法

使用npm包进行bootstrap基本上会添加一些额外的输入绑定来帮助你完成工作.

从Reddit,

ng-bootstrap gives you Angular input bindings for all the parameters
you might need to tweak. If you’re just doing the basics then there
isn’t much difference. But as soon as you need to access a Bootstrap
property that isn’t controlled by a CSS class,then with vanilla
Bootstrap you have to do very un-angularish $(dom-id) references in
your Javascript logic,whereas if you’re using ng-bootstrap that action
is accomplished by tweaking a property that’s bound to the
ng-bootstrap component.

我个人使用vanilla Bootstrap并包含jquery.我以前读过以避免包含这样的jquery但它还没有给我带来任何问题.但它可能会让一些事情变得困难.我使用标签和可扩展卡时遇到问题.即使使用ng2,我也必须创建布尔值来跟踪它们是否被扩展.

使用它没有任何问题.它可能更好,更安全.

Another pro of using ng version is its light weight because of:
* not using jquery

  • readiness to use es2015 modules and lazy loading

  • readiness for tree-shaking to minimize the size

  • being ready to use any bundling type you want

  • template precompiling

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读