如何向 ionic 4 应用程序添加和使用 bootstrap?
How can I add and use bootstrap to an ionic 4 app?
我正在构建一个 ionic 4 应用程序,我想在不使用 CDN 方法的情况下使用 bootstrap。我已经使用 npm install bootstrap.
安装了 bootstrap
使用 Ionic 4,可以使用 angular.json 文件轻松完成此操作
打开angular.json文件,该文件位于项目的根目录下
找到样式数组,将路径添加到下载的 bootstrap 文件
"styles": [
{
"input": "src/theme/variables.scss"
},
{
"input": "src/global.scss"
},
{
"input": "node_modules/bootstrap/dist/css/bootstrap.min.css"
}
],
如果您想使用 bootstrap 脚本,请将 bootstrap 脚本也添加到脚本数组中。
请注意:要使用bootstrap脚本,需要将jquery和popper.js添加到您的项目中还有
使用链接。
和
使用 ionic serve
重新运行 ionic 4
只需将 BootstrapCDN 粘贴到 src/index 的 header 中即可。html。
- 在 ionic 应用程序文件夹中创建新文件夹 public/css。
- 在 public/css 中粘贴 bootstrap.min.css 的副本。
- 在angular.json.
中添加"public/css/bootstrap.min.css"字符串路径
*确保重建您的应用。>ionic serve
我正在构建一个 ionic 4 应用程序,我想在不使用 CDN 方法的情况下使用 bootstrap。我已经使用 npm install bootstrap.
安装了 bootstrap使用 Ionic 4,可以使用 angular.json 文件轻松完成此操作
打开angular.json文件,该文件位于项目的根目录下
找到样式数组,将路径添加到下载的 bootstrap 文件
"styles": [
{
"input": "src/theme/variables.scss"
},
{
"input": "src/global.scss"
},
{
"input": "node_modules/bootstrap/dist/css/bootstrap.min.css"
}
],
如果您想使用 bootstrap 脚本,请将 bootstrap 脚本也添加到脚本数组中。
请注意:要使用bootstrap脚本,需要将jquery和popper.js添加到您的项目中还有
使用链接。
和 使用 ionic serve
重新运行 ionic 4只需将 BootstrapCDN 粘贴到 src/index 的 header 中即可。html。
- 在 ionic 应用程序文件夹中创建新文件夹 public/css。
- 在 public/css 中粘贴 bootstrap.min.css 的副本。
- 在angular.json. 中添加"public/css/bootstrap.min.css"字符串路径
*确保重建您的应用。>ionic serve