Last active
June 17, 2021 09:50
-
-
Save Lxxyx/c128c25b5344e6f552d578329bae9f79 to your computer and use it in GitHub Desktop.
文件路由 Params 设计
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 默认情况 | |
// /lambda/article/[id].ts | |
export default async (id: string) => { | |
return id | |
} | |
export const content = (id: string) => { | |
// id = req.params.id = 路径 | |
return id | |
} | |
// GET /api/article/MarkTwain => MarkTwain | |
// GET /api/article/Hemingway/content => Hemingway | |
// 嵌套 | |
// /lambda/[user]/history/[year].ts | |
export default async (user: string, year: string) => { | |
return id | |
} | |
// 可以匹配,/api/jack/history/35,req.params = { user: jack, year: 35 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment