react int转换为string toString()
refer https://stackabuse.com/javascript-convert-number-to-string/
react中使用toString可以把int转换为string:
例如:
let a = 20
a.toString(); // '20'const myInt = 42;
const myString = myInt.toString();完整的例子:
import React from 'react';
class MyComponent extends React.Component {
render() {
const myInt = 42;
const myString = myInt.toString();
return (
<div>
<p>整数: {myInt}</p>
<p>字符串: {myString}</p>
</div>
);
}
}