loveyou1
V2EX  ›  问与答

关于 React + Ts useState 问题

  •  
  •   loveyou1 · Aug 10, 2020 · 1904 views
    This topic created in 2126 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 有没有更好的写发吗,这样太恶心了

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   890 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:31 · PVG 06:31 · LAX 15:31 · JFK 18:31
    ♥ Do have faith in what you're doing.