File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -796,7 +796,7 @@ updateMyTodos(draft => {
796
796
797
797
<Challenges>
798
798
799
- ### 更新购物车中的商品 {/*update-an-item-in-the-shopping-cart*/}
799
+ #### 更新购物车中的商品 {/*update-an-item-in-the-shopping-cart*/}
800
800
801
801
填写 ` handleIncreaseClick` 的逻辑,以便按下“+”时递增对应数字:
802
802
@@ -923,7 +923,7 @@ button { margin: 5px; }
923
923
924
924
</Solution>
925
925
926
- ### 删除购物车中的商品 {/*remove-an-item-from-the-shopping-cart*/}
926
+ #### 删除购物车中的商品 {/*remove-an-item-from-the-shopping-cart*/}
927
927
928
928
现在购物车有了一个正常工作的“+”按钮,但是“-”按钮却没有任何作用。你需要为它添加一个事件处理程序,以便按下它时可以减少对应商品的 ` count` 。如果在数字为 1 时按下按钮,商品需要自动从购物车中移除。确保商品计数永远不出现 0。
929
929
@@ -1084,7 +1084,7 @@ button { margin: 5px; }
1084
1084
1085
1085
</Solution>
1086
1086
1087
- ### 使用不会直接修改原始值的方法修复 mutation 的问题 {/*fix-the-mutations-using-non-mutative-methods*/}
1087
+ #### 使用不会直接修改原始值的方法修复 mutation 的问题 {/*fix-the-mutations-using-non-mutative-methods*/}
1088
1088
1089
1089
在下面的例子中,` App .js ` 中所有的事件处理程序都会产生 mutation。这导致编辑和删除待办事项的功能无法正常运行。使用不会直接修改原始值的方法重写 ` handleAddTodo` 、` handleChangeTodo` 和 ` handleDeleteTodo` 这三个函数:
1090
1090
@@ -1417,7 +1417,7 @@ ul, li { margin: 0; padding: 0; }
1417
1417
</Solution>
1418
1418
1419
1419
1420
- ### 使用 Immer 修复 mutation 的问题 {/*fix-the-mutations-using-immer*/}
1420
+ #### 使用 Immer 修复 mutation 的问题 {/*fix-the-mutations-using-immer*/}
1421
1421
1422
1422
下面的例子和上一个挑战的相同。这次,你需要使用 Immer 来修复 mutation 的问题。为了方便,` useImmer` 已经被引入了,你需要使用它来替换 ` todos` 的 state 变量。
1423
1423
You can’t perform that action at this time.
0 commit comments