> ## Documentation Index
> Fetch the complete documentation index at: https://bun.ll1025.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 将 HTML 文件作为文本导入

要在 Bun 中将 `.html` 文件作为文本文件导入，请在 import 语句中使用 `type: "text"` 属性。

```ts file.ts icon="https://mintcdn.com/span-inc/82N53aP7NFbaCVSl/icons/typescript.svg?fit=max&auto=format&n=82N53aP7NFbaCVSl&q=85&s=787d39d6a7d96d7f9540dc74344eba23" theme={null}
import html from "./file.html" with { type: "text" };

console.log(html); // <!DOCTYPE html><html><head>...
```

启用热模块重载或监听模式时，只要 `./file.html` 发生变化，Bun 就会重新加载。
