Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
单页应用
|
179
致性、保证性能以及保证组件间的通信。
你大概也会好奇环绕着度假产品的看起来像空组件的东西(
<>...</>
)。它被称为
fragment
。这个
fragment
是必要的
,因为每个组件都必须渲染成单个元素。在这种情形中
有两个元素,即
<h2>
和
<div>
。这个
fragment
只是提供一个能容纳这两个元素的“透明”
的根元素,这样我们才能将其渲染成单个元素。
把
Vacations
组件加入应用,即便它还没有度假产品可以显示。在
client/src/App.js
中,首
先导入度假产品页:
import Vacations from './Vacations'
然后在
<Switch>
路由组件中为它创建一个路由:
<Switch>
<Route path="/" exact component={Home} />
<Route path="/about" exact component={About} />
<Route path="/vacations" exact component={Vacations} />
<Route component={NotFound} />
</Switch>
保存文件,应用应该会自动重新加载,然后就可以导航到
/vacations
页了,尽管现在还没
有什么东西可看。现在,我们的客户端已经有了大部分的基础设施,接下来看看如何跟
Express
集成起来。
16.4.4
 度假产品页
——
跟服务器端集成
我们已经完成了建立度假产品列表页的大部分工作,也有了一个从数据库获取度假产品并 ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua
前端架构设计

前端架构设计

Micah Godbolt

Publisher Resources

ISBN: 9787115565099