Create a React+Typescript project

Next, let's explore using TypeScript to write react,
insert image description here
which is also a very good trend, and it is currently used by many people
, so let's start by creating a project

First of all, we first find a directory or create a directory to put our project in
insert image description here
, and then directly enter it in this directory
. For example, here I want to create a project called tsReApp, which can be entered

npx create-react-app tsreapp --template typescript

There is no way this command does not support uppercase, so the name has to be changed from uppercase to lowercase.
insert image description here
Then we checked the directory and found that the project has been created.
Here, everyone must understand the concept of npx.
He means that if your project If there is a dependency needed to execute this command, he will use the dependency. If not, he will install the dependency first and then create it. Then let’s
insert image description here
talk about a digression. The
official recommendation is that we use VSCode. Generally, the front-end computer should have this tool, and it is very useful.
insert image description here
Then we Open the newly created project with VSCode.
In package.json, we can see that the startup command is start and
insert image description here
we execute it directly on the terminal.

npm run start

insert image description here
Then the browser side is also normal
insert image description here
, but this has to admit that the compilation speed of the Ts project will be slightly slower than that of the ES project

Guess you like

Origin blog.csdn.net/weixin_45966674/article/details/132271857