react之点语法(利用函数组件)
index.js
import React, { Component } from 'react' import MyCom from './MyCom'; export default class extends Component { constructor (props) { super(props); } render () { return ( <div> <h1>高阶组件</h1> <MyCom.Coma /> <MyCom.Comb /> </div> ) } }
MyCom.js
import React from 'react'; export default { Coma () { return (<h1>Coma</h1>) }, Comb () { return (<h1>Comb</h1>) } }
App.js
import React, { Component } from 'react' import MyCom from './MyCom'; export default class extends Component { constructor (props) { super(props); } render () { return ( <div> <h1>高阶组件</h1> <MyCom.Coma /> <MyCom.Comb /> </div> ) } }
长风破浪会有时,直挂云帆济沧海