V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
loveyou1
V2EX  ›  问与答

关于 React + Ts useState 问题

  •  
  •   loveyou1 · 2020-08-10 13:03:22 +08:00 · 1306 次点击
    这是一个创建于 1352 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题

    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 有没有更好的写发吗,这样太恶心了

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1253 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 23:23 · PVG 07:23 · LAX 16:23 · JFK 19:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.