shop.jsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { useState } from "react";
  2. import { Link } from "react-router-dom";
  3. import './shop.css'
  4. const list = [
  5. {
  6. id: 1,
  7. name: "孙悟空",
  8. age: 20,
  9. describe: "金箍棒",
  10. },
  11. {
  12. id: 2,
  13. name: "猪八戒",
  14. age: 22,
  15. describe: "九齿钉耙",
  16. },
  17. {
  18. id: 3,
  19. name: "沙和尚",
  20. age: 24,
  21. describe: "月牙铲",
  22. },
  23. ];
  24. function Shop() {
  25. let [newList] = useState(list);
  26. return (
  27. <div className="shop">
  28. <table>
  29. <thead>
  30. <tr>
  31. <th>序号</th>
  32. <th>名字</th>
  33. <th>年龄</th>
  34. <th>武器</th>
  35. <th>操作</th>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. {/* <td>1</td>
  40. <td>aaa</td>
  41. <td>23</td>
  42. <td>121212</td> */}
  43. {newList.map((item, index) => (
  44. <tr key={index}>
  45. <td>{index + 1}</td>
  46. <td>{item.name}</td>
  47. <td>{item.age}</td>
  48. <td>{item.describe}</td>
  49. <td>
  50. <Link to={{pathname:`/shop/details/${item.id}`}}>详情</Link>
  51. </td>
  52. </tr>
  53. ))}
  54. </tbody>
  55. </table>
  56. </div>
  57. );
  58. }
  59. export default Shop;