You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
785 B

import React, {Component} from 'react';
import PubSub from 'pubsub-js'
class New extends Component {
constructor(props) {
super(props);
this.state = {
num: 5,
ztext: 'yasaka'
}
}
fun = () => {
this.setState({num: this.state.num + 1})
}
render() {
return (
<div>
父组件传过来值为 ---- {this.props.text} -- {this.state.num}
<button onClick={this.fun}>click</button>
<button onClick={this.props.call.bind(this,this.state.ztext)}>up data</button>
<button onClick={()=>{
PubSub.publish("vtt","call you!")
}}>call pub</button>
</div>
);
}
}
export default New;