小编joe*_*une的帖子

为什么 Next.js 的 req.query 对象的值是字符串类型 | 细绳[]?

Next.js 的 API 路由接收一个对象 - 它是http.IncomingMessagereq的扩展,带有附加中间件,例如. 在他们的utils.ts中找到的的类型是:req.queryreq.query

query: {
    [key: string]: string | string[]
}
Run Code Online (Sandbox Code Playgroud)

为什么可以从查询中接收字符串数组?

我正在尝试对查询值执行字符串方法,但遇到 TS 错误 -_-

someString.split() // => Property 'split' does not exist on type 'string | string[]'.
Run Code Online (Sandbox Code Playgroud)

node.js typescript next.js

13
推荐指数
1
解决办法
6345
查看次数

标签 统计

next.js ×1

node.js ×1

typescript ×1