카테고리 없음

[모난] Angular 2에서 "속성 X가 유형 오류로 누락되었습니다."

필살기쓰세요 2021. 1. 16. 18:07

클래스 conf에서 속성을 선택 사항 으로 만들어야합니다 Tooltip.

export class Tooltip implements TooltipConfig {
  text:string;
    label:string;
      conf?:(any);
      
        constructor(c:TooltipConfig) {
            this.text = c.text;
                this.label = c.label;
                    c.conf && (this.conf = c.conf);
                      }
                      }
                      

또는 TooltipConfig인터페이스의 tooltip속성 유형으로 인터페이스 를 사용해야합니다 Section.

export interface Section {
  //...
    digitalSkills?:{
        skills?:{
              name:string,
                    tooltip:TooltipConfig 
                        }
                        }
                        

또는 개체 생성에서 Tooltip 클래스를 인스턴스화 할 수 있습니다.

{
  //...
    digitalSkills: {
        skills: [
              {
                      name: '...',
                              tooltip: new Tooltip({
                                        text: '...',
                                                  label: '...'
                                                          })
                                                                },
                                                                      {
                                                                              name: '...',
                                                                                      tooltip: new Tooltip({
                                                                                                text: '...',
                                                                                                          label: '...'
                                                                                                                  })
                                                                                                                        }
                                                                                                                            ],
                                                                                                                                 //...
                                                                                                                                   }
                                                                                                                                     //...
                                                                                                                                     }
                                                                                                                                     

샘플 코드를 살펴보십시오 .



출처
https://stackoverflow.com/questions/39915968