若要將 .html
檔案匯入 Bun 作為文字檔案,請在匯入陳述式中使用 type: "text"
屬性。
import html from "./file.html" with { type: "text" };
console.log(html); // <!DOCTYPE html><html><head>...
這也可以與熱模組重新載入和/或監控模式一起使用,以強制 Bun 在 ./file.html
檔案變更時重新載入。
此功能已新增至 Bun v1.1.5。
若要將 .html
檔案匯入 Bun 作為文字檔案,請在匯入陳述式中使用 type: "text"
屬性。
import html from "./file.html" with { type: "text" };
console.log(html); // <!DOCTYPE html><html><head>...
這也可以與熱模組重新載入和/或監控模式一起使用,以強制 Bun 在 ./file.html
檔案變更時重新載入。
此功能已新增至 Bun v1.1.5。
HTTP
讀取檔案
執行時間
工具程式
WebSocket