index.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React, {Component} from 'react'
  2. import { NavBar } from 'antd-mobile';
  3. import CartItem from "./CartItem";
  4. import CartEdit from "./CartEdit";
  5. class Cart extends Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. content:true
  10. }
  11. }
  12. changeCartPage =()=>{
  13. this.setState({
  14. content:!this.state.content
  15. })
  16. };
  17. render() {
  18. let {content} = this.state;
  19. return (
  20. <div>
  21. <NavBar
  22. mode="light"
  23. style={{borderBottom: '1px solid #ebedf0'}}
  24. rightContent={[
  25. <span key={"1"} onClick={this.changeCartPage}>
  26. {content ? "编辑":"完成"}
  27. </span>
  28. ]}
  29. >购物袋
  30. </NavBar>
  31. {
  32. content ?
  33. <CartItem/>:<CartEdit/>
  34. }
  35. </div>
  36. )
  37. }
  38. }
  39. export default Cart