1.1.9 开始支持
    支持 props 传入 JSX,但是元素传入 JSX 的属性名必须以 render 开头
    例如,子组件写法

    1. class Dialog extends Component {
    2. render () {
    3. return (
    4. <View className='dialog'>
    5. <View className='header'>
    6. {this.props.renderHeader}
    7. </View>
    8. <View className='body'>
    9. {this.props.children}
    10. </View>
    11. <View className='footer'>
    12. {this.props.renderFooter}
    13. </View>
    14. </View>
    15. )
    16. }
    17. }

    父组件调用子组件时传入 JSX

    1. class App extends Component {
    2. render () {
    3. return (
    4. <View className='container'>
    5. <Dialog
    6. renderHeader={
    7. <View className='welcome-message'>Welcome!</View>
    8. }
    9. renderFooter={
    10. <Button className='close'>Close</Button>
    11. }
    12. >
    13. <View className="dialog-message">
    14. Thank you for using Taro.
    15. </View>
    16. </Dialog>
    17. </View>
    18. )
    19. }
    20. }