【问题标题】:How to pass property of Integer in React?如何在 React 中传递 Integer 的属性?
【发布时间】:2020-02-11 14:00:56
【问题描述】:

我知道if string的写法是

this.state ={event_email: ''}

但是如果我需要的值是整数呢?

this.state={id: //??}

【问题讨论】:

  • 你可以在jsx中使用id:0id:null,在typescript中你可以定义interface

标签: reactjs constructor integer long-integer


【解决方案1】:

在文档中找到:https://reactjs.org/docs/react-component.html#constructor

constructor(props) {
  super(props);
  this.state = { id: 0 };
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-03
    • 2018-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-31
    • 2021-03-16
    • 1970-01-01
    相关资源
    最近更新 更多