【问题标题】:angular-cli: how to add external libraries (jquery, bootstrap)angular-cli:如何添加外部库(jquery、bootstrap)
【发布时间】:2016-09-20 13:03:05
【问题描述】:

目前我必须做的:

  • 安装本地库npm install bootstrapnpm install jquery
  • 创建文件夹src\assets
  • 复制 node_modules\bootstrap 和 node_modules\jquery 中的所有文件

在 index.html 中

<script src="assets/jquery/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">

有更好的方法吗?

【问题讨论】:

  • 它在文档中字面上说如何做到这一点。

标签: angular npm angular-cli


【解决方案1】:

读完你就明白了:

https://github.com/angular/angular-cli#3rd-party-library-installation

基本上您只需将其添加到angular-cli.json 文件(apps[0])中的scripts 属性即可。

"scripts": [
  "../node_modules/jquery/dist/jquery.js",
  "../node_modules/tether/dist/js/tether.js",
  "../node_modules/bootstrap/dist/js/bootstrap.js"
]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-15
    • 1970-01-01
    • 1970-01-01
    • 2015-01-14
    • 1970-01-01
    相关资源
    最近更新 更多