Coursera 笔记

Module 01 · Introduction to React and Class ComponentsReact 与类组件简介

Lab: Content Rating Application to Like or Dislike Content实验:内容点赞与点踩评分应用

In this lab, you will create a React component called 'ContentRating' where the component will let users rate material by clicking 'like' or 'dislike' buttons. When the component is rendered for the first time, both the like and dislike counts are set to zero. You will create a method that changes the state to add one to the number of likes when a user selects the 'like' button. In the same way, clicking the 'dislike' button, the method will add one to the number of dislikes. This action lets users rate the content in an interactive way and provides useful input to content creators.
在这个实验室中,您将创建一个名为“ContentRating”的 React 组件,该组件允许用户通过点击“点赞”或“踩”按钮来评分材料。当组件首次渲染时,点赞和踩的数量都设置为零。您将创建一个方法,当用户选择“点赞”按钮时,该方法将状态改变以将点赞数量加一。同样,点击“踩”按钮时,该方法将踩的数量加一。这一操作让用户能够以互动的方式对内容进行评分,并为内容创作者提供有用的反馈。

📄 实验:内容评分应用程序以喜欢或不喜欢内容.pdf