Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
React学习手册
by
Alex Banks
,
Eve Porcello
December 2017
Intermediate to advanced
329 pages
6h 9m
Chinese
China Electric Power Press Ltd.
Content preview from
React学习手册
266
|
第
11
章
集成
Router
为了演示
React Router
的功能特性,我们将会构建一个经典的初级网站,其中包括
About
、
Events
、
Products
和
Contact Us
等段落(见图
11-1
)。虽然这个网站看上去似
乎包含多个页面,但是实际上只有一个:它是一个单页应用(
SPA
)。
图
11
-
1
:公司网站主页
该网站的导航地图包括一个主页,一个显示每个段落的页面,以及用于处理“
404 Not
Found
”的错误提示页面(见图
11-2
)。
图
11
-
2
:页面标题和路由
router
将会允许用户为网站的每个段落配置路径。每个路径都是可以在浏览器地址栏
输入的端点。当某个路径被请求后,我们可以渲染显示相应的内容。
React Router
|
267
HashRouter
react-router-dom
提供了一对选项用于管理单页应用中的导航历史记录。
HashRouter
是专门为客户端而设计的。一般来说,地址栏上的哈希字符是用于
定义锚点链接的。当在地址栏中使用
#
时,浏览器并不会向服务端发送请求。
在使用
HashRouter
时,所有路径前面的
#
将一直是必不可少的。
HashRouter
对于新项目或者不需要后端服务的小型客户端网站是非常好的工
具。
BrowserRouter
是大部分准备上线的网站应用首选的解决方案。在第 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
React快速上手开发
Stoyan Stefanov
流畅的Python
Luciano Ramalho
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
C++程序设计:原理与实践(基础篇)(原书第2版)
本贾尼 斯特劳斯特鲁普
Publisher Resources
ISBN: 9787519814236