How can i add and use bootstrap to an ionic 4 app

末鹿安然 提交于 2019-12-07 06:15:07

问题


Im building an ionic 4 application and i want to use bootstrap with out using the CDN method. I have installed bootstrap with npm install bootstrap.


回答1:


With Ionic 4, this can be done easily by making use of the angular.json file

open the angular.json file, this can be located at the root of your project

locate the the styles array, add the path to the downloaded bootstrap file

"styles": [
          {
            "input": "src/theme/variables.scss"
          },
          {
            "input": "src/global.scss"
          },
          {
            "input": "node_modules/bootstrap/dist/css/bootstrap.min.css"
          }
        ],

if you wish to make use of bootstrap scripts, add the bootstrap script to the scripts array as well.

Please note: for you to make use of bootstrap scripts, jquery and popper.js are required to be added to your projects as well




回答2:


  1. create new folder public/css inside ionic app folder.
  2. inside public/css paste copy of bootstrap.min.css.
  3. add "public/css/bootstrap.min.css" string path in angular.json.

*make sure to rebuild your app .>ionic serve




回答3:


Just paste the BootstrapCDN into the header of src/index.html.




回答4:


Go With Links.

1.techiediaries

2.youtube

and rerun ionic 4 using ionic serve



来源:https://stackoverflow.com/questions/53063005/how-can-i-add-and-use-bootstrap-to-an-ionic-4-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!