[英]Loading basic HTML in Node.js inside string "html"
您好,我在想是否有任何方法可以在 node.js 中加載 HTML 作為
app.get("/html") 中的 string 就像 "<-html->blabla"... 一個正常但在 node.js 代碼中因為我想將數據庫值放在其中而不是靜態的有沒有辦法做到這一點? 或者至少做我正在尋找的
要使用express.js
發送格式化字符串,您可以執行以下操作:
app.get("/html", async (req, res) => {
const msg = await getMsgFromDB(); // An example of how you fetch data from DB
res.send(`<!DOCTYPE html>${msg}</html>`);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.