Nodejs學習(五) 動態網頁

2021-08-09 08:59:04 字數 625 閱讀 5992

將資料(後台或者前端獲得)與html模板相結合, 在前端顯示實際資料

首先需要在html模板中將要顯示的資料標記出來, 例如可以用{}標記

email:

password:

然後利用正規表示式將實際資料替換到標記處內容, 實現顯示實際資料。

//----------login-------------------------

var post='';//定義乙個post變數, 用於暫存請求資訊

req.on('data', function

(chunk));

//-------注意非同步-------------

req.on('end', function

()','g');

datastr = datastr.replace(re,post[arr[i]])

}res.write(datastr.tostring());

res.end();

}

optfile.readfile('./views/login.html', recall)

});

經典動態網頁學習書籍

head first html with css xhtml html pocket reference css pocket reference css cookbook cascading style sheets the definitive guide html xhtml the defi...

準動態網頁

為描述上的方便,先定義四條術語 純靜態磁碟網頁,純靜態記憶體網頁,準動態網頁,純動態網頁 純靜態磁碟網頁 指的是在客戶端在請求網頁時,該網頁已經預先拼接成html並生成在磁碟上.純靜態記憶體網頁 指的是在客戶端在請求網頁時,該網頁已經預先拼接成html並生成在記憶體中.code 準動態網頁 指的是在...

動態網頁D html

bom browser object model 瀏覽器物件模型 window物件 window 代表瀏覽器中開啟的乙個視窗 1 alert 方法 定義乙個訊息對話方塊 window.alert windows 2 confirm 方法 定義乙個確認對話方塊 var res window.confi...