【问题标题】:having toubles importing bootstrap4-toggle to angular 8有问题将 bootstrap4-toggle 导入 Angular 8
【发布时间】:2019-11-19 20:20:18
【问题描述】:

我是 Angular 的新手,我正在尝试从以下来源导入 bootstrap4-toggle: https://gitbrent.github.io/bootstrap4-toggle/#api 到我的项目中添加一个切换复选框:) 我运行 npm install 并在 packjage.json 中找到项目中的包,现在我需要将它添加到“样式”但我不知道要添加什么,我已经尝试过

 "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "node_modules/bootstrap4-toggle/css/bootstrap4-toggle.min.css",
              "src/styles.css",
              "node_modules/font-awesome/css/font-awesome.css"
            ],

但它没有工作...... 我在导航栏中使用了这个标签

<input type="checkbox" checked data-toggle="toggle">

它应该看起来像一个切换按钮,而不是看起来像一个普通的 html 复选框。

【问题讨论】:

  • 你怎么知道它不起作用?您收到错误消息吗?请尽可能多地分享细节。
  • 也许你应该只使用标准的、纯 CSS 的,并避免在你的应用程序中添加对 jQuery 的依赖:getbootstrap.com/docs/4.3/components/forms/#switches
  • 脚本下也需要导入 bootstrap4-toggle.min.js。
  • @JBNizet,hbamithkumara - 两个建议都有效,谢谢!
  • @error86 - 答案似乎已由某人发布,并且您接受了它。请不要编辑您的问题以说“已解决”或将解决方案放在问题中 - 这不是问题所在,这些是对问题的无效编辑。如果您想发布一个额外的答案,除了发布的答案之外还有细节,那就太好了。因此...我回滚了您上次的编辑。

标签: angular bootstrap-4


【解决方案1】:

在 angular.json 中的脚本和样式中添加导入

"styles": [
    "src/styles.css",
    "node_modules/bootstrap4-toggle/css/bootstrap4-toggle.min.css"
],
"scripts": [
    "node_modules/bootstrap4-toggle/js/bootstrap4-toggle.min.js"
]

【讨论】:

    猜你喜欢
    • 2018-07-10
    • 2018-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多