随笔分类 - React
摘要:Fetch API 已经成为前端应用中获取资源的原生方式。 在这篇文章中,我将展示如何用 async/await 语法使用 Fetch API 的常见场景。目的是让你对如何获取数据、处理获取错误、取消获取请求等有信心。 开始之前,推荐熟悉 async/await 语法。在下面的例子中将广泛使用它。
阅读全文
摘要:Fetching data from third-party RESTful APIs in React application is a common task when creating web application. This task can be solved easily by usi
阅读全文
摘要:Disclaimer There are multiple possible ways of using React with a backend framework -- steps presented below are showing one possible way of connectin
阅读全文
摘要:Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to the
阅读全文
摘要:An onChange event is triggered when values are entered in the input. This fires a function handleChange(), that is used to set a new state for the inp
阅读全文
摘要:map是一种数据集合类型,其中数据以对的形式存储。它包含一个唯一的键,存储在映射中的值必须映射到键。我们不能在map()中存储重复的对,这是因为每个存储的键都是惟一的,它主要用于快速搜索和查找数据。 在React里map方法用于遍历和显示组件的类似对象列表,map不是React特有的,相反,它是可以
阅读全文
摘要:什么是React Hook? hook(钩子)是一种特殊的函数,它允许你“钩入”各种React特性。假设一个函数返回一个有两个值的数组: 第一个值: 一个带有状态state的变量。 第二个值: 一个带有处理程序handle(改变当前状态的函数)的变量。 就是这样,很简单。🥞 记住,在JavaScr
阅读全文
摘要:1. npm安装 下载node.js: nodejs.org/en/download… 命令行下输入: npm -v 验证是否安装成功。 2. cnpm安装 安装命令: npm install -g cnpm --registry=https://registry.npm.taobao.org 命令
阅读全文