Du kan inte välja fler än 25 ämnen
Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
30 rader
785 B
30 rader
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;
|