//父组件

import * as React from 'react'
import { Input } from 'antd'
const Search = Input.Search
import "./index.less"
import Child from "./compon/list"
interface IProps {

  MakeMoney?: () => void    //暴露方法
}
export default class ProjectList extends React.Component<IProps>{
constructor(props: IProps) {
super(props) }
MakeMoney(){  //子组件调用父组件的方法
alert("我在学习react!");
}
render(){
return (
<div>
<div className="Input_box">
<div style={{ marginBottom: 16 }}>
<Search
placeholder="搜索"
onSearch={value => console.log(value)}
onChange={this.Inpchange}
enterButton
/>
<button>点击切换</button>
</div>
</div>
<Child MakeMoney={this.MakeMoney}/>//子组件
</div>
)
}
}
//子组件
import * as React from 'react'
import { Row, Col } from 'antd';
import "./list.less"
interface IProps {
msg?: any
MakeMoney?:any  //获取暴露的方法
}
interface IState {
lg?: any }
export default class List extends React.Component<IProps, IState> {
constructor(props: IProps) {
super(props) }
StudyMakeMoney=()=>{ // 调用父组件方法
this.props.MakeMoney();
}
render(){
const { lg } = this.state;
return (
<div>
<button onClick={this.StudyMakeMoney}>子组件</button>
  </div>
}

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

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

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

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

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

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

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

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

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

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

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

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

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

  7. react 子组件调用父组件方法

    import React from 'react'import '../page1/header.css'import { Table } from 'antd'import Child from ' ...

  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. 《Java设计模式》之解释器模式

    解释器模式是类的行为模式.给定一个语言之后,解释器模式能够定义出其文法的一种表示,并同一时候提供一个解释器. client能够使用这个解释器来解释这个语言中的句子. 解释器模式的结构 以下就以一个示意 ...

  2. POJ_1679_The Unique MST(次小生成树模板)

    The Unique MST Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23942   Accepted: 8492 D ...

  3. 『干货』分享你最喜欢的技巧和提示(Xcode,objective-c,swift,c...等等)

    亲爱的读者们,你们好 !年底将近,分享从过去一年你最喜欢的技巧和建议作为礼物送给新手们.提交你的最喜欢的迅速或objc琐事,实用的提示,意外的发现,实用的解决方法,没用的迷恋,或不论什么其它你认为今年 ...

  4. LinearLayout (线性布局)的分析

    android提供了5中布局,线性布局,相对布局,帧布局.表格布局和绝对布局 线性和相对布局用的是最多的 以下要说的是线性布局 提到线性布局 一定要记住.它里面的全部组件一定不会重叠的, 切不会换行. ...

  5. s:actionmessage页面样式失效

    1,  s:actionmessage页面样式失效: 2,解决方式: 将样式直接写入s:actionmessage标签中:<span><s:actionmessage cssSt ...

  6. jQuery 自定义动画效果

    <!DOCTYPE html> <html> <head> <script src="/jquery/jquery-1.11.1.min.js&qu ...

  7. Linux 学习之路:认识shell和bash

    一.shell  计算机硬件的直接控制者是操作系统的内核(kernel),因为内核的重要性,所以作为用户的我们是无法直接操作内核的,所以我们需要shell调用应用程序或者双击打开安装的应用软件与内核之 ...

  8. 51nod 1353 树

    树背包 设f[i][j]表示第i个点,和子节点组成的联通块大小为j,其他都可行的方案 j=0表示可行的总方案 #include<cstdio> #include<iostream&g ...

  9. [Codeforces 485F] Oppa Funcan Style Remastered

    [题目链接] https://codeforces.com/contest/986/problem/F [算法] 不难发现 , 每个人都在且仅在一个简单环中 , 设这些环长的长度分别为 A1, A2 ...

  10. ubuntu下的路由实验

    这个实验先演示两个client是如何通过路由器进行通信的. 我们至少需要三个虚拟机:clientA.clientB和route. 对clientA的网卡进行设置: #the primary netwo ...