Tencent / omi

Web Components Framework - Web组件框架

Home Page:http://omijs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

能否支持在 web component 中引入 JSX 组件?

rowthan opened this issue · comments

问题:一个 web-component 组件内容太多时,将部分内容单独拆分出来利于管理。但拆出来的部分并不希望成为一个新的 web-component。

作用:

  1. react 的组件写法更简单一些
  2. 可以将类函数组件包裹到 web-component 中,方便项目迁移和兼容。
  3. 每一个组件均使用 web-component 有一点心智负担(性能)。

例如

@tag('web-component')
class WebComponent extends Component {
   render(){

    return(
       <div>
          标题
         <div>内容很多... 希望能抽出逻辑,以类 react function 组件的形式使用</div>
       </div>
    )
  }
}

=》

function Content(){
   return(
     <div>内容很多... 希望能抽出逻辑,以类 react function 组件的形式使用</div>
   )
}

@tag('web-component')
class WebComponent extends Component {
   render(){

    return(
       <div>
          标题
         <Content></Content >
       </div>
    )
  }
}

不错的建议。我看下怎么支持这个特性。

支持了。aa7143d

v7.5.0