|
@@ -0,0 +1,49 @@
|
|
|
+import { useState } from 'react';
|
|
|
+import { Link } from 'react-router-dom';
|
|
|
+
|
|
|
+const initialProducts = [
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ name: '篮球',
|
|
|
+ price: '$29.9',
|
|
|
+ desc: '这是郭老师玩过的篮球,具有巨星风采',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 2,
|
|
|
+ name: '足球',
|
|
|
+ price: '$129.9',
|
|
|
+ desc: '这是郭老师当年勇夺女子足球联赛冠军所用,具有巨星风采!!',
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+function Products() {
|
|
|
+ let [products] = useState(initialProducts);
|
|
|
+ return (
|
|
|
+ <div className="products">
|
|
|
+ <table>
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>#</th>
|
|
|
+ <th>Name</th>
|
|
|
+ <th>Price</th>
|
|
|
+ <th>Action</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ {products.map((p, i) => (
|
|
|
+ <tr key={p.id}>
|
|
|
+ <td>{i + 1}</td>
|
|
|
+ <td>{p.name}</td>
|
|
|
+ <td>{p.price}</td>
|
|
|
+ <td>
|
|
|
+ <Link to={{ pathname: `/products/details/${p.id}` }}>详情</Link>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ ))}
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+export default Products;
|