【问题标题】:No styles applied to angular-2-dropdown-multiselect没有样式应用于 angular-2-dropdown-multiselect
【发布时间】:2018-12-20 10:56:09
【问题描述】:

我在我的 Angular 项目中使用 angular-2-dropdown-multiselect 和 Angular CLI。

我能够让它在我的项目中工作,但由于某种原因没有应用任何样式。我也安装了 bootstrap 3 和 FontAwesome,因为文档声称这些是依赖项。

更新

请注意,更新 bootstrap 对我来说不是一个选项,因为项目非常大,其余布局基于 bootstrap3

谁能帮我弄清楚发生了什么?

Here is a demo of the issue

【问题讨论】:

标签: css angular angular6


【解决方案1】:

您需要正确设置路径,否则它将无法工作,并将您的 boostrap 更新到最新版本,它将工作 检查你的例子我编辑了https://stackblitz.com/edit/angular-xyg8hy

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

【讨论】:

  • 嗯,路径似乎没有问题。如果您单击并打开下拉菜单,您会看到那里存在样式问题
  • 可能是你的 boostrap 是旧版本更新到 boostrap 4..stackblitz.com/edit/angular-xyg8hy
  • 谢谢,但不幸的是,更新 bootstrap 对我来说不是一个选择,因为项目很大,其余布局基于 bootstrap3
【解决方案2】:

这里 iam 更新了您的 stackblitz iam 在 index.html 文件中添加了引导程序 https://stackblitz.com/edit/angular-h3jrnu

效果很好

<html>
<head>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
</head>
<body>
    <my-app>loading</my-app>
</body>

如果你不使用 bootstrap 4 使用这个

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css

编辑:-

注意:- angular-2-dropdown-multiselect 仅使用 bootstrap 4。看截图,

截图,

编辑2:- index.html

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

【讨论】:

  • 谢谢,但不幸的是,更新 bootstrap 对我来说不是一个选择,因为项目很大,其余布局基于 bootstrap3
  • 我注意到您已经更改了 index.html 中提到的引导程序版本,但问题仍然存在,并且在使用 NPM 和 Angular CLI 时,在 head 部分包含脚本也不是应该做的事情
  • 自述文件中明确提到该库支持 bootstrap 3 github.com/softsimon/…
  • 可能是库的问题,我会在github上开一个issue。感谢您的宝贵时间
  • 是的,我看到了。但是那个插件没有使用 bootstrap 3。如果使用 angular cli go node modules 文件夹并访问那个包 index.html
【解决方案3】:

查看 angular-2-dropdown-multiselect 的 releases,我注意到 Boostrap 4 支持是在 1.7 版中引入的。

我尝试降级到版本 1.6.3,样式问题已得到修复。所以我猜文档中关于支持最新版本的 bootstrap 3 是错误的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-12
    • 1970-01-01
    • 2020-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多