javascript - 将引导插件添加到 Angular 8
问题描述
我是 Angular 的新手,并试图弄清楚如何将 Bootstrap 插件,特别是Bootstrap Toggle引入 Angular 8。这是我尝试过的。
已安装bootstrap
, jquery
, popper.js
,bootstrap-toggle
在angular.json
我添加
"styles": [
"src/styles.css",
"./node_modules/bootstrap-toggle/css/bootstrap-toggle.min.css",
"./node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/popper.js/dist/umd/popper.min.js",
"./node_modules/bootstrap-toggle/js/bootstrap-toggle.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js"
]
在app.module.ts
我添加的
import bootstrap from "bootstrap";
然后为了测试,我将以下内容添加到app.component.html
<div class="container">
<p> Please enter your name</p>
<form class="form-inline">
<div class="form-group col-sm-12 justify-content-center">
<div class="col-sm-6">
<input class="form-control" style="width:100%" #invitation>
</div>
<button type="submit" class="btn btn-primary">Search</button>
</div>
</form>
<input type="checkbox" checked data-toggle="toggle">
</div>
复选框未更改为切换。任何想法为什么?
解决方案
尝试像这样添加
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="switch1">
<label class="custom-control-label" for="switch1">Toggle me</label>
</div>
推荐阅读
- javascript - JavaScript:在两个对象数组中查找匹配和差异
- jquery - 未捕获的类型错误:无法读取 shopify 自定义购物车弹出 jQuery ajax 中未定义的属性“id”
- sql - 替换部分字符串并更新 STANDARD SQL 中的列
- matplotlib - 如何将布尔矩阵转换为灰度图?
- java - 在 liquibase 中默认分配角色
- r - 在“NAMESPACE”中指定但未在包中定义的 S4 导出
- json - 我想解析 JSON 对象,以便我可以显示 JSON 条目表,而不是直接将 JSON 对象显示为 jsp 中的输出
- html - 攻击者如何规避这一点
- python - 如何将具有多个 Docker 容器的应用程序部署到 AWS Elastic Beanstalk?
- python - 腌制所有变量