Skip to content

不接受分配给本地的值。

LocalsNotAnObject:locals 只能分配给一个对象。不接受数字、字符串等其他值。

¥LocalsNotAnObject: locals can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.

¥What went wrong?

locals 被非对象覆盖时抛出

¥Thrown when locals is overwritten with something that is not an object

例如:

¥For example:

import {defineMiddleware} from "astro:middleware";
export const onRequest = defineMiddleware((context, next) => {
context.locals = 1541;
return next();
});
Astro 中文网 - 粤ICP备13048890号