React官網零基礎學習筆記(1)-本地環境搭建

本教程提供两种方式来开始React项目:一种是在浏览器中直接编写代码,快速上手;另一种是在本地计算机上搭建开发环境,适合深入学习。教程详细介绍了如何使用Create React App创建新项目,并配置本地编辑器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

官網原文:

Setup for the Tutorial

There are two ways to complete this tutorial: you can either write the code in your browser, or you can set up a local development environment on your computer.

 

Setup Option 1: Write Code in the Browser

This is the quickest way to get started!

First, open this Starter Code in a new tab. The new tab should display an empty tic-tac-toe game board and React code. We will be editing the React code in this tutorial.

You can now skip the second setup option, and go to the Overview section to get an overview of React.

 

Setup Option 2: Local Development Environment

This is completely optional and not required for this tutorial!

 

Optional: Instructions for following along locally using your preferred text editor

選擇option2:

Optional: Instructions for following along locally using your preferred text editor

This setup requires more work but allows you to complete the tutorial using an editor of your choice. Here are the steps to follow:

1.Make sure you have a recent version of Node.js installed.

2.Follow the installation instructions for Create React App to make a new project.

npx create-react-app my-app

3.Delete all files in the src/ folder of the new project

Note: don’t delete the entire src folder, just the original source files inside it.. We’ll replace the default source files with examples for this project in the next step.

cd my-app
cd src

# If you're using a Mac or Linux:
rm -f *

# Or, if you're on Windows:
del *

# Then, switch back to the project folder
cd ..

4.Add a file named index.css in the src/ folder with this CSS code.

5.Add a file named index.js in the src/ folder with this JS code.

6.Add these three lines to the top of index.js in the src/ folder:

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';

Now if you run npm start in the project folder and open http://localhost:3000 in the browser, you should see an empty tic-tac-toe field.

We recommend following these instructions to configure syntax highlighting for your editor.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值