Angular5 tslint錯誤:The selector of the component 「XXXComponent」 should be used as element

錯誤描述

在項目中本身封裝了一個 select 組件css

@Component({
    selector: '[app-choosen-select]',
    templateUrl: './selectcommon.component.html',
    styleUrls: ['./style.scss']
})
export class SelectCommonComponent implements OnInit, AfterViewInit, OnDestroy {

ts編譯報錯。html

解決方案

修改tslint.jsonjson

"component-selector": [
      true,
      "element",
      "app",
      "kebab-case"
    ],

改成app

"component-selector": [
      true,
      ["element","attribute"],
      "app",
      "kebab-case"
    ],

組件引用

<div app-choosen-select [options]="groupOptions" class="cpu-select-round"></div>
相關文章
相關標籤/搜索