React中实现类似vue动态组件效果
2019-06-29 本文已影响0人
情有千千节
render
{/* 动态组件 */}
{
this.state.showCom ?
<section className={style['full-screen']}>
{ this.showCom() }
</section>
: ''
}
showCom = () => {
const name = this.state.comName
switch (name) {
case 'Course':
return <Course/>
default:
break;
}
}