像这样,能方便很多。
return ( <div class="input-group"> {this.$slots.default && this.$slots.default.map(item => { //如果 item 是个 vue component return item.componentOptions ? (<item></item>) : (item) })} </div> );
![]() | 1 oyhw92 2019-01-10 16:04:24 +08:00 //如果 item 是个 vue component return item.componentOptions ? this.$createElement(item) : (item) |
2 MerlinLord OP @oyhw92 #1 cannot:( |
![]() | 3 WenJimmy 2019-01-10 16:22:41 +08:00 <item /> ? |
![]() | 4 TomVista 2019-01-10 16:25:07 +08:00 渲染出 item 后,重新声明定义一个 item 组件. |
![]() | 5 TomVista 2019-01-10 16:38:57 +08:00 |
![]() | 6 TomVista 2019-01-10 16:46:47 +08:00 @MerlinLord vm.$forceUpdate(); 这个函数, |