TotoListUI.js 2.57 KB
Newer Older
mayi's avatar
mayi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

import React from "react";
import "antd/dist/antd.css";
import { Input, Button, List } from "antd";
const TotoListUI = (props) =>{
    return (
              <div style={{ margin: "10px" }}>
                <div>
                  <Input
                    value={props.inputValue}
                    placeholder={props.inputValue}
                    style={{ width: "250px", marginRight: "10px" }}
                    onChange={(e) => props.changeInputValue(e)}
                  />
                  <Button type="primary" onClick={() => props.addValue()}>
                    增加
                  </Button>
                </div>
                <div style={{ margin: "10px", width: "300px" }}>
                  <List
                    bordered
                    dataSource={props.list}
                    renderItem={(item, index) => (
                      <List.Item>
                        {item}
                        <Button
                          type="danger"
                          onClick={() => props.deleteItem(index)}
                        >
                          删除
                        </Button>
                      </List.Item>
                    )}
                  />
                </div>
              </div>
            );
}
// import { CHANGE_INPUT,ADD_ITEM,DELETE_ITEM} from "./store/actionsTypes";
// class TotoListUI extends Component {
//   // constructor(props) {
//   //     super(props);
//   //     this.state = {  }
//   // }
//   //把ui部分写成无状态组件
//   render() {
//     return (
//       <div style={{ margin: "10px" }}>
//         <div>
//           <Input
//             value={this.props.inputValue}
//             placeholder={this.props.inputValue}
//             style={{ width: "250px", marginRight: "10px" }}
//             onChange={(e) => this.props.changeInputValue(e)}
//           />
//           <Button type="primary" onClick={() => this.props.addValue()}>
//             增加
//           </Button>
//         </div>
//         <div style={{ margin: "10px", width: "300px" }}>
//           <List
//             bordered
//             dataSource={this.props.list}
//             renderItem={(item, index) => (
//               <List.Item>
//                 {item}
//                 <Button
//                   type="danger"
//                   onClick={() => this.props.deleteItem(index)}
//                 >
//                   删除
//                 </Button>
//               </List.Item>
//             )}
//           />
//         </div>
//       </div>
//     );
//   }
// }

export default TotoListUI;