nodejs中服務器返回響應信息中的中文亂碼

const express=require('express');
var server=express();
server.use('/a.html',function (req,res) {
    res.send('ok').end();
})
server.get('/b.html',function (req,res) {
    res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});//只須要設置響應頭的編碼格式就好
    res.write('write只能寫字符串和buffer');
    console.log(res.writeHead);
    res.end();
})
server.listen(8080);```
相關文章
相關標籤/搜索