构建 Express 应用:从基础功能到移动友好设计
1. 查看笔记功能实现
- 路由配置 :在
routes/notes.js中添加如下路由函数,用于处理/notes/view路径的请求。
router.get('/view', (req, res, next) => {
notes.read(req.query.key)
.then(note => {
res.render('noteview', {
title: note ? note.title : "",
notekey: req.query.key,
note: note
});
})
.catch(err => { next(err); });
});
- 视图模板 :在
views目录下添加noteview.ejs模板文件,用于展示笔记内容。
<!DOCTYPE html>
<html>
<head>
<% include headerStuff %>
</head>
<body&g
超级会员免费看
订阅专栏 解锁全文
1012

被折叠的 条评论
为什么被折叠?



