React004 route
tags
React.js
type
Post
date
Nov 5, 2023
status
Published
安装 route包
App.js 里设置路由,这里面包含了固定地址,exact,路由里传递参数,以及404 not found页面 才用* 匹配路由,并且放在最后一个位置。
Navbar.js Link标签替代 a标签,这样页面请求不会向服务器端发送请求
BlogList.js 通过Link标签链接到博客内容页,这里的是用 `` 反引号
BlogDetail.js 通过 react的 useParams 来获取 url来的参数
NotFound.js 404页面
界面效果
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F2fc301d0-472d-48f0-85e3-f4327a85cd35%2Fb8d283f3-5868-434b-bb92-a5d92d690a53%2FUntitled.png?table=block&id=41cc00b9-1406-4cb2-8d0a-058d640cd0d8&cache=v2)