loveyou1
V2EX  ›  问与答

关于 React + Ts useState 问题

  •  
  •   loveyou1 · Aug 10, 2020 · 2254 views
    This topic created in 2279 days ago, the information mentioned may be changed or developed.

    问题

    interface Group {
      tag: string;
      css: CssGroup[];
      dom: DocumentFragment | HTMLElement | null;
      children: AstGroup[];
      attrs?: CssGroup[];
      additionalCss: CssGroup[];
      text?: string;
      isRoot?: boolean;
      isRow?: boolean;
    }
    const [currentObj, setCurrentObj] = useState<Group>();
    

    我不要 currentObj 的初始值,会导致使用 currentObj 的属性时候( currentObj as Group ).attrs 有没有更好的写发吗,这样太恶心了

    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5182 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 06:23 · PVG 14:23 · LAX 22:23 · JFK 01:23
    ♥ Do have faith in what you're doing.