Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. /*****************
  2. * 按钮
  3. *****************/
  4. var Button = React.createClass({
  5. style:function(){
  6. var style={
  7. padding:"0 16px",
  8. backgroundColor:"#fff",
  9. height: "30px",
  10. lineHeight: "30px",
  11. border: "1px solid #ddd",
  12. borderRadius: "2px",
  13. cursor: "pointer"
  14. }
  15. if (this.state.hovered) {
  16. style = Object.assign(style,{boxShadow:"0 1px 3px rgba(0,0,0,.2)"})
  17. }
  18. if (this.props.type=="back"){
  19. style = Object.assign(style,{margin: "3px 5px"})
  20. }else{
  21. style = Object.assign(style,{position:"absolute",
  22. bottom: "60px",
  23. right: "60px",
  24. color: "white",
  25. backgroundColor:"#fd5e51"
  26. })
  27. }
  28. return style
  29. }
  30. ,
  31. onMouseOver : function () {
  32. this.setState({ hovered:true });
  33. }
  34. ,
  35. onMouseOut : function () {
  36. this.setState({ hovered:false });
  37. }
  38. ,
  39. getInitialState : function() {
  40. return { hovered: false }
  41. }
  42. ,
  43. render(){
  44. return (
  45. <button className={"btn btn_"+this.props.type}
  46. onClick={this.props.handleClick}
  47. onMouseOver={this.onMouseOver}
  48. onMouseOut={this.onMouseOut}
  49. style={this.style()}
  50. >
  51. {Data.KVMapping.button[this.props.type]}
  52. </button>
  53. )
  54. }
  55. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement