Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic property names & template strings 举例不恰当 #74

Open
phoenix-yassin opened this issue Jun 5, 2017 · 0 comments
Open

Dynamic property names & template strings 举例不恰当 #74

phoenix-yassin opened this issue Jun 5, 2017 · 0 comments

Comments

@phoenix-yassin
Copy link

ES5可以写成:
var Todo = React.createClass({
onChange: function(inputName, e){
this.setState({
[iputName + 'Value']:e.target.value,
})
}
})
ES6可以写成:
class Todo extends React.Component({
onChange(inputName, e){
this.setState({
[${inputName}Value]: e.targe.value,
})
}
})

这样区别不大

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant