工作生活

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;
    }
  }

上一篇 下一篇

猜你喜欢

热点阅读