角度自定义CSS类未在视图中出现

问题描述 投票:0回答:1

我正在使用角度formio,因为我使用的是自定义css类,名称为CustomCSS,我已经在css文件中添加了相同的内容,如下所示

这里是stackblitz

app.component.scss

.CustomCSS {
    margin: auto;
  width: 50%;
  border: 3px solid rgb(1, 248, 1);
  padding: 10px;
    background-color: coral;
  }

app.component.ts

    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.scss']
    })
    export class AppComponent implements OnInit {

ngOnInit() {
    debugger;
    this.triggerRefresh = new EventEmitter();
    this.http.get('http://....')
    .subscribe(
      response  => {
        this.form = response.json();// this is my html script from DB
      },
        err => {console.error(err)}
    ); 

   }
}

app.component.html

<formio [refresh]="triggerRefresh" [form]="form" [submission]="submission" (submit)="onSubmit($event)"></formio>

我的HTML this.form脚本如下

{
   "components":[
      {
         "label":"City",
         "widget":"choicesjs",
         "customClass":"CustomCSS",
         "tableView":true,
         "data":{
            "values":[
               {
                  "label":"abc",
                  "value":"abc"
               ]
         },
         "selectThreshold":0.3,
         "calculateServer":false,
         "validate":{
            "required":true
         },
         "key":"city",
         "type":"select",
         "indexeddb":{
            "filter":{

            }
         },
         "input":true
      },
      {
         "type":"button",
         "label":"Submit",
         "key":"submit",
         "disableOnInvalid":true,
         "input":true,
         "tableView":false
      }
   ],
   "id":4
}

在我的脚本中,css类名也可用,但是它没有追加到视图中。

html css angular formio
1个回答
2
投票

使它在组件中起作用的一种可能方法是修改该组件的样式封装。

© www.soinside.com 2019 - 2024. All rights reserved.