亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

角度自定義 css 類未在視圖中附加

角度自定義 css 類未在視圖中附加

MM們 2023-09-18 16:33:38
我正在研究 Angular Formio,因為我正在使用自定義 css 類,名稱CustomCSS我在 css 文件中添加了相同的名稱,如下所示這是堆棧閃電戰應用程序組件.scss.CustomCSS {    margin: auto;  width: 50%;  border: 3px solid rgb(1, 248, 1);  padding: 10px;    background-color: coral;  }應用程序組件.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)}    );    }}應用程序組件.html<formio [refresh]="triggerRefresh" [form]="form" [submission]="submission" (submit)="onSubmit($event)"></formio>我的Htmlthis.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 類名也可用,但它沒有附加在視圖中。
查看完整描述

1 回答

?
縹緲止盈

TA貢獻2041條經驗 獲得超4個贊

使其在您的組件中工作的一種可能方法是修改該組件的樣式封裝。


import { Component, OnInit, ViewEncapsulation } from '@angular/core'; // <-- add ViewEncapsulation?


@Component({

? selector: 'my-app',

? templateUrl: './app.component.html',

? styleUrls: [ './app.component.css' ],

? encapsulation: ViewEncapsulation.None // <-- add this line

})


話雖如此。


我仍然建議使用全局樣式并實現 css 選擇器來定位 formio 生成的 html 元素,如您的示例所示:


#app formio .control-label {

? font-weight: bold;

}


查看完整回答
反對 回復 2023-09-18
  • 1 回答
  • 0 關注
  • 89 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號