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>
    )
  }
}

 

posted @ 2019-11-21 20:19  菜鸟小何  阅读(347)  评论(0编辑  收藏  举报