import React from 'react'
import '../page1/header.css'
import { Table } from 'antd'
import Child from './child'//引入的子组件

export default class Header extends React.Component{
  constructor(){
  super()

  }

}

MakeMoney(){
  alert("我在学习react!");
}

render(){

  return (<div>

    <Child MakeMoney={this.MakeMoney} />

  </div>

}

//子组件

import React from 'react'

export default class Header extends React.Component{
  constructor(props){
  super(props)
 
}
StudyMakeMoney=()=>{ // 调用父组件方法
  this.props.MakeMoney();
}
render(){
console.log(this.props.msg)
return (
  <div className="header">
    <button onClick={this.StudyMakeMoney}>调用父组件中的方法</button>  //点击按钮通过StudyMakeMoney方法中this.props.MakeMoney();
  </div>
)
}
}

react 子组件调用父组件方法的更多相关文章

  1. React篇-子组件调用父组件方法,并传值

    react 中子组件调用父组件的方法,通过props: 父组件: isNote(data){} <div className="tabC01"> <FTab ta ...

  2. react typescript 子组件调用父组件

    //父组件 import * as React from 'react'import { Input } from 'antd'const Search = Input.Searchimport &q ...

  3. vue 子组件调用父组件的方法

    vue中 父子组件的通信: 子组件通过 props: { //子组件中写的. childMsg: { //字段名 type: Array,//类型 default: [0,0,0] //这样可以指定默 ...

  4. Vue子组件调用父组件的方法

    Vue子组件调用父组件的方法   Vue中子组件调用父组件的方法,这里有三种方法提供参考 第一种方法是直接在子组件中通过this.$parent.event来调用父组件的方法 父组件 <temp ...

  5. Vue中子组件调用父组件的方法

    Vue中子组件调用父组件的方法 相关Html: <!DOCTYPE html> <html lang="en"> <head> <meta ...

  6. Vue 子组件调用父组件 $emit

    <!DOCTYPE html><html>    <head>        <meta charset="utf-8">      ...

  7. vue 子组件调用父组件的函数

    子组件调用父组件的函数,使用$emit(eventName,[...args]),触发当前实例上的事件.附加参数都会传给监听器回调. 子组件 <template> <div> ...

  8. react 父组件调用子组件方法、子组件调用父组件方法

    我们闲话不多说,直接上代码 // 父组件 import React, {Component} from 'react'; class Parents extends Component { const ...

  9. react 中子组件调用父组件的方法

    1.在父组件中定义方法,并绑定在子组件上 // 在子组件中调用父组件中的方法 import React,{Component} from 'react'; import Child from './c ...

随机推荐

  1. C++学习之普通函数指针与成员函数指针

    函数指针(function pointer)是通过指向函数的指针间接调用函数.相信很多人对指向一般函数的函数指针使用的比较多,而对指向类成员函数的函数指针则比较陌生.我最近也被问到了这方面的问题,心中 ...

  2. 转 BlockingQueue(阻塞队列)详解

    转自 http://wsmajunfeng.iteye.com/blog/1629354 前言: 在新增的Concurrent包中,BlockingQueue很好的解决了多线程中,如何高效安全“传输” ...

  3. poj-1635 Subway tree systems(推断两个有根树是否同构)-哈希法

    Description Some major cities have subway systems in the form of a tree, i.e. between any pair of st ...

  4. bzoj2538: [Ctsc2000]公路巡逻

    超车这个东西这么恶心肯定是要暴力求的(自圆其说) 那么分成一个个时间段来搞,然后DP一下 化一下那个速度,耗费时间是在300s~600s之间的 那我们就可以设f[i][j]为走到第i个位置用了j的时间 ...

  5. 【模板】 倍增lca

    虽然很基础,但是还是复习了一下,毕竟比树剖好写... 代码: #include<iostream> #include<cstdio> #include<cmath> ...

  6. openStack aio 测试

  7. ubuntu 16.04 Hbase 安装

    1.解压安装包至路径 /usr/local 1.1.sudo tar -zxf ~/下载/hbase-1.1.2-bin.tar.gz -C /usr/local 2.将解压的文件名hbase-1.1 ...

  8. 不使用c的任何库函数 实现字符串到整数的转换 整数到字符串的转换

    转载请标明出处:http://www.cnblogs.com/NongSi-Net/p/6805844.html 今天主要总结下:完成编程: 1.除printf函数之外,不用任何c语言库函数,实现将字 ...

  9. B. Trees in a Row(cf)

    B. Trees in a Row time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  10. git配置用户信息

    git配置用户信息 一.在本地配置用户信息 配置内容:user.name 和 user.email 配置目的:Git用来记录谁做了什么事 配置方法:windows下打开Git Bash进行操作  gi ...