Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译为小程序时,自定义组件不支持使用children #56

Closed
yaoyonstudio opened this issue Jun 10, 2018 · 2 comments
Closed

Comments

@yaoyonstudio
Copy link

请问为什么自定义组件不能使用children呢?
这应该是比较常用的需求了,定义一个或多个布局组件,�然后页面上只需要引入所需的布局组件就好了。

在H5模式下貌似没发现总是,但是打包成小程序后无法使用。

import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import AppHeader from '../common/AppHeader.js'

export default class MainLayout extends Component {
  render () {
    return (
      <View className='MainLayout'>
      	<AppHeader backicon={this.props.backicon} title={this.props.title}></AppHeader>
        <View className='Main'>
        	{this.props.children}
        </View>
      </View>
    )
  }
}
@yuche
Copy link
Contributor

yuche commented Jun 10, 2018

因为目前小程序内置的组件化方案才能用 slot,但是内置组件化不能通过 props 传函数,所以我们自己目前做的一套组件化系统可以传函数,但不能传组件。

文档也有写:
https://nervjs.github.io/taro/jsx.html

@yaoyonstudio
Copy link
Author

明白了,谢谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants