跳转到内容
This is an unmaintained snapshot of the Astro v4 docs. View the latest docs.

Value assigned to locals is not accepted.

LocalsNotAnObject: locals 只能被赋值为一个对象。不接受如数字、字符串等其他值。

locals 被赋值为一个非对象时抛出错误。

例如:

import { defineMiddleware } from "astro:middleware";
export const onRequest = defineMiddleware((context, next) => {
context.locals = 1541;
return next();
});
贡献

你有什么想法?

社区