问题
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:
- create new folder public/css inside ionic app folder.
- inside public/css paste copy of bootstrap.min.css.
- 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