更新时间:2022-06-16 02:23:51
您尝试调用 split
的类型是 string|string[]
,这意味着value 可以是 string
或 string[]
,为了让 TypeScript 满意,两种类型都必须有 split
方法.如果您确信它始终是一个字符串,请在调用 split
之前更新定义(如果可能)或强制转换为 string
:
The type you are trying to invoke split
on is string|string[]
, which means that value may be either a string
or a string[]
, in order for TypeScript to be happy, BOTH types must have a split
method. If you are confident that it will always be a string, either update the definition (if possible) or cast to a string
before calling split
:
(<string>req.headers.authorization).split
或
(req.headers.authorization as string).split