我正在使用https://www.npmjs.com/package/angular4-jsoneditor中的Angular4-JsonEditor。
我能够以树格式看到 JSON 。我还提到了如上所述的 css ,但有些样式没有得到应用。它显示如下所示。即使我尝试将自己的样式添加到现有的类中,也没有应用任何更改。我是角色的新手可以请一些人指导我。
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";
答案 0 :(得分:1)
您需要将导入添加到src/style.css
@import "~jsoneditor/dist/jsoneditor.min.css";