我在React JS项目中有一个组件,用于显示一些文本。文本变量的类型是字符串,并且其中包含一些制表符转义字符。我想用div替换这个制表符,以便在渲染HTML时,在渲染输出div时能在span标签内看到。因此,在浏览器的页面源代码中,我希望看到像这样的内容 => <span> once upon a time, <div> there was a man <div> who had a house. </span>
文本 = "once upon a time, \t there was a man \t who had a house." ;
class somcomponent extends React.Component {
render() {
return <span> {text}</span>;
}
}