【问题标题】:Angular4-JsonEditor css is missing缺少 Angular4-JsonEditor css
【发布时间】:2018-08-21 17:57:41
【问题描述】:

我正在使用来自https://www.npmjs.com/package/angular4-jsoneditor 的 Angular4-JsonEditor。

我能够看到树格式的 JSON。如前所述,我还导入了 css,但有些样式未得到应用。它显示如下所示。即使我尝试将自己的样式添加到现有的类中,也不会应用任何更改。我是 Angular 的新手,请有人指导我。

app.component.ts

 import { Component,ViewChild } from '@angular/core';
 import { NgJsonEditorModule } from 'ang-jsoneditor' ;

@Component({
selector: 'app-root',
template: `<json-editor [options]="editorOptions" [data]="data"></json-
 editor>`,
 styleUrls: ['./app.component.css']
  })
export class AppComponent {
public editorOptions: JsonEditorOptions;
public data: any;
@ViewChild(JsonEditorComponent) editor: JsonEditorComponent;

 constructor() { 

var options = {
  "mode": "tree",
  "search": true
};
this.editorOptions = new JsonEditorOptions();
this.editorOptions.mode="view";
this.editorOptions.search=false;


this.data={"products":[{"name":"car","product":[{"name":"honda","model":
[{"id":"civic","name":"civic"},{"id":"accord","name":"accord"},
{"id":"crv","name":"crv"},{"id":"pilot","name":"pilot"},
{"id":"odyssey","name":"odyssey"}]}]}]}
}
}

}

app.component.css

 @import "~jsoneditor/dist/jsoneditor.min.css";

【问题讨论】:

    标签: javascript css angular typescript sass


    【解决方案1】:

    您需要将导入添加到src/style.css

    @import "~jsoneditor/dist/jsoneditor.min.css";
    

    【讨论】:

    • 谢谢,它起作用了..为什么当我将它添加到 app.component.css 时它不起作用? oi 已经在 styleUrls 中为该组件提供了这个?
    • 是关于执行的时间。 Style.css 首先运行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-06
    • 1970-01-01
    • 2018-11-27
    • 2015-12-31
    • 1970-01-01
    相关资源
    最近更新 更多