Angular5 tslint错误:The selector of the component “XXXComponent” should be used as element

错误描述

在项目中自己封装了一个 select 组件

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

ts编译报错。

解决方案

修改tslint.json

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

改为

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

组件引用


<div app-choosen-select [options]="groupOptions" class="cpu-select-round"></div>

猜你喜欢

转载自www.cnblogs.com/liulei-cherry/p/10008595.html