简体   繁体   English

如何在 angular 项目中包含 popper.js 和 bootstrap.js

[英]How to include popper.js and bootstrap.js in angular project

I am using angular with openlayers and I am following the example posted below in the link:我正在将 angular 与 openlayers 一起使用,并且我正在按照下面链接中发布的示例进行操作:

        https://openlayers.org/en/latest/examples/overlay.html

the aforementioned link provide the following information in order to work with the popover:上述链接提供以下信息以使用弹出框:

Things to know when using the popover plugin:
Popovers rely on the 3rd party library Popper.js for positioning. You must include popper.min.js before bootstrap.js or use bootstrap.bundle.min.js / bootstrap.bundle.js which contains Popper.js in order for popovers to work!

please let me know how to include请让我知道如何包含

popper.js 

and

bootstrap.js 

so i can work with the popover function and get it working.所以我可以使用弹出框 function 并让它工作。

image :图片

在此处输入图像描述

You can add node_modules/dist/css/boostrap.min.css in styles under the build section of angular.json file BEFORE src/styles.css . You can add node_modules/dist/css/boostrap.min.css in styles under the build section of angular.json file BEFORE src/styles.css . You can download the bootstrap from the npm package npm install bootstrap您可以从 npm package npm install bootstrap下载引导程序

In order to work with the pop ups you can add the bundle file of bootstrap node_modules/bootstrap/dist/js/bootstrap.bundle.min.js in the scripts under the build section of the same file.为了使用弹出窗口,您可以在同一文件的 build 部分下的脚本中添加 bootstrap node_modules/bootstrap/dist/js/bootstrap.bundle.min.js的捆绑文件。

EDIT: You have to download JQuery and add it to your scripts section as well.编辑:您必须下载 JQuery 并将其添加到您的脚本部分。

for external JavaScript or any file that you want to implement on angular.对于外部 JavaScript 或您想要在 angular 上实现的任何文件。 you have to set path for that files on angular.json file您必须在 angular.json 文件上设置该文件的路径

angular.json angular.json

在此处输入图像描述

for angular older version need set path on .angular.cli.json对于 angular 旧版本需要在.angular.cli.json上设置路径

Note :- after changes on angular.json file, you have to recompile or restart project.注意:- 在 angular.json 文件更改后,您必须重新编译或重新启动项目。

you can import files into index.html file.您可以将文件导入index.html文件。 在此处输入图像描述

Just use npm to install:-只需使用 npm 安装:-

[propper]: > https://www.npmjs.com/package/propper [proper]: > https://www.npmjs.com/package/propper

npm i propper --save npm i propper --save

[bootstrap]: > https://www.npmjs.com/package/bootstrap [引导程序]:> https://www.npmjs.com/package/bootstrap

npm i bootstrap --save npm i bootstrap --save

There are some step that you have to follow.您必须遵循一些步骤。

-1. Install Jquery like npm instll jquery -save
-2. Install latest bootStrap npm install bootstrap@4.3.1 --save
-3. Install Popper js like npm install popper.js --save

And then add styles and scripts into angular.json file like然后将 styles 和脚本添加到 angular.json 文件中,如在此处输入图像描述

======================================================================== ==================================================== =======================

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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