跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com

实时重载

最后更新 查看 MarkdownAgent 设置

当 liveReload 设置为 true 时,Miniflare 会在 Worker 脚本 变更时自动刷新浏览器。

const mf = new Miniflare({
	liveReload: true,
});

Miniflare 只会在 Content-Type 标头设置为 text/html 的 响应末尾注入实时重载所需的 <script> 标签:

export default {
	fetch() {
		const body = `
      <!DOCTYPE html>
      <html>
      <body>
        <p>Try update me!</p>
      </body>
      </html>
    `;

		return new Response(body, {
			headers: { "Content-Type": "text/html; charset=utf-8" },
		});
	},
};

这篇文档对您有帮助吗?