<h1>关于</h1>

问题描述 投票:0回答:1

我使用来自 自定义处理程序 | 的示例代码新鲜文档:

import { Handlers } from "$fresh/server.ts";

export const handler: Handlers = {
  async GET(_req, ctx) {
    const resp = await ctx.render();
    resp.headers.set("X-Custom-Header", "Hello");
    return resp;
  },
};

export default function AboutPage() {
  return (
    <main>
      <h1>About</h1>
      <p>This is the about page.</p>
    </main>
  );
}

我收到此错误

error: Uncaught (in promise) TypeError: The module's source code could not be parsed: Unterminated regexp literal at file:///D:/QC%20supplements/Code/Apps/T%E1%BA%A1o%20v%C3%A0%20r%C3%BAt%20g%E1%BB%8Dn%20link%20UTM/Web/routes/index.ts:14:17

        <h1>About</h1>
                  ~~~~
  const manifest = (await import(toFileUrl(join(dir, "fresh.gen.ts")).href))
                    ^
    at async dev (https://deno.land/x/[email protected]/src/dev/dev_command.ts:38:21)
    at async file:///D:/QC%20supplements/Code/Apps/T%E1%BA%A1o%20v%C3%A0%20r%C3%BAt%20g%E1%BB%8Dn%20link%20UTM/Web/dev.ts:8:1
Watcher Process failed. Restarting on file change...

为什么会出现这种情况?看起来像是一个错误。

regex literals deno freshjs
1个回答
0
投票

JSX 代码不能在

.jsx
.tsx
文件之外使用。将
routes/index.ts
重命名为
routes/index.tsx
可以使其再次工作。我认为 Deno 也应该抓住这一点并警告/建议用户。

© www.soinside.com 2019 - 2024. All rights reserved.