【问题标题】:How to add the css file reference in angular.json? ngx-smart-modal - Angular如何在 angular.json 中添加 css 文件引用? ngx-smart-modal - 角
【发布时间】:2019-07-27 00:04:06
【问题描述】:

我按照这个 StackBlitz 示例:https://stackblitz.com/edit/ngx-smart-modal-example 添加了 ngx-smart-modal 窗口,但该组件在页面上而不是在模式弹出窗口中打开。谁能告诉我如何解决这个问题,或者如果解决了这个问题,如何添加 css 文件引用?

  • 我绑了很多东西,
  • 我尝试关注这篇文章的前 2 个答案:ngx-smart-modal - Angular 6 但没有运气:

  • 我尝试添加以下行:

"node_modules/ngx-smart-modal/ngx-smart-modal.css",

到该部分:

 "styles": [
          ],

在 angular.json 中

  • 我尝试添加该行:

    @import "../node_modules/ngx-smart-modal/ngx-smart-modal.css";

进入 src/styles.css 文件并添加: 行: “src/styles.css” 到部分

"styles": [    
              ],

在 angular.json 中

...

       "styles": [

              "./node_modules/ngx-smart-modal/ngx-smart-modal.css"

        ],
...

【问题讨论】:

标签: html angular typescript


【解决方案1】:

您的 stackblitz 示例使用 ngx-smart-modal@2.0.4,但我们目前使用的是 @7.1.1。

我建议您遵循Setup 模态的官方文档。

而不是绝对路径,使用相对路径作为@import "~ngx-smart-modal/ngx-smart-modal.css";

【讨论】:

    【解决方案2】:

    我遵循了一些步骤,但没有运气,所以我转到另一个确实有效的示例:https://www.youtube.com/watch?v=Jm9q9Alva0M,代码位于:https://stackblitz.com/edit/ngx-modal

    但我必须添加以下行:

    在“app.component.html”文件的顶部,然后出现了模态页面。

    【讨论】:

    • 不幸的是,这不是同一个包。这不是您问题的答案。
    猜你喜欢
    • 1970-01-01
    • 2018-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多