简体   繁体   中英

angular-cli: how to add external libraries (jquery, bootstrap)

Currently I have to do:

  • install local libs npm install bootstrap and npm install jquery
  • create a folder src\\assets
  • copy all files in node_modules\\bootstrap and node_modules\\jquery

In 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">

Any better way?

Read this and you will understand:

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

Basically you just have to add it to the scripts property in the angular-cli.json file ( apps[0] ).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM