如何在ReactJS中添加"colSpan"属性

Lam*_*ert 34 typescript reactjs

当我尝试将colSpan ="2"属性添加到下面的ReactJS TypeScript代码时,我收到错误" Type string is not assignable to type number " .我怎样才能解决这个问题?

class ProductCategoryRow extends React.Component<MyProps, MyState> {
   constructor(props: MyProps) {
      super(props);
   }
   render() {
      return (<div>
         <tr><th colSpan="2">{ this.props.category }</th></tr>
      </div>);
   } //end render.
} //end class.
Run Code Online (Sandbox Code Playgroud)

Ser*_*res 75

你试过<th colSpan={2}>{ this.props.category}</th>吗?