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

# 将 HTML 文件作为文本导入

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

```ts file.ts icon="https://mintcdn.com/bun-zhcndoc/cnUTwgMuf4cCrwC-/icons/typescript.svg?fit=max&auto=format&n=cnUTwgMuf4cCrwC-&q=85&s=e7767043c9e885c34f2d6c8fe2a95217" theme={"theme":{"light":"github-light","dark":"dracula"}}
import html from "./file.html" with { type: "text" };

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

这也可以与热模块重载和/或监听模式一起使用，以强制 Bun 在 `./file.html` 文件更改时重新加载。
