首页 新闻 会员 周边

nodejs中文乱码

1
悬赏园豆:5 [已关闭问题] 关闭于 2012-07-12 10:33

最近在研究nodejs,写了一个测试例子,结果中文都是乱码,不知如何解决

var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/html"});
response.write(
'<!doctype html>'+
'<html>'+
'<head>'+
'<meta charset="utf-8"/>'+
'<title>米诺</title>'+
'</head>'+
'<body>'+
'<a href="/home.js">主页</a>'+
'<a href="/contact.js">Contact</a>'+
'</body>'+
'</html>');
response.end(); }).listen(8888);
console.log("服务启动");

在浏览器中标题"米诺"和l链接"主页"都为乱码,控制台"服务启动"四个字显示为空行.

另外,有没有什么办法不用框架就可以让html和js代码分离,每写一句html都要用引号和加号忒麻烦.

灿飞的主页 灿飞 | 初学一级 | 园豆:2
提问于:2012-07-11 10:48
< >
分享
所有回答(2)
0

res.sendfile(__dirname+'/index.htm')

幕三少 | 园豆:1384 (小虾三级) | 2015-11-13 20:45
0

 

我这里运行时正常的啊

 

node初级 | 园豆:204 (菜鸟二级) | 2017-02-19 10:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册