在React JSX中,似乎不可能做这样的事情:
render: function() {
return (
<{this.props.component.slug} className='text'>
{this.props.component.value}
</{this.props.component.slug}>
);
}Run Code Online (Sandbox Code Playgroud)
我得到一个解析错误:意外的令牌{.这不是React可以处理的吗?
我正在设计这个组件,以便在引擎盖下,存储的值this.props.component.slug将包含有效的HTML元素(h1,p等).有没有办法让这项工作?