Skip to content

Commit

Permalink
Update 04-react路由.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Daotin authored Mar 13, 2020
1 parent af4462d commit 3a4627c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions 17-React/04-react路由.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,10 @@ componentDidMount() {

如果要传递大量数据,使用`state`进行传递,这种传递的方式**不会在地址栏显示。**

···
<Link to={{ pathname: `/detail/${item.goodsId}`, state: { name: item.name, price: item.price } }} key={item.goodsId} >
<h3>名称:{item.name}</h3>
<p>价格:{item.price}</p>
</Link >
···
```
{ pathname: `/detail/${item.goodsId}`, state: { name: item.name, price: item.price } }
```


> 这种state传参的写法,需要注意to的值不再是字符串拼接,而是一个对象。
Expand Down

0 comments on commit 3a4627c

Please sign in to comment.