var http = require('http');
var handler = function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World!');
}
http.createServer(handler).listen(8080);
但這並不
var http = require('http');
http.createServer(handler).listen(8080);
var handler = function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World!');
}
我不明白爲什麼,因爲它應與吊裝更加我沒有錯誤。
因爲你的天堂」 t定義處理程序了嗎?當它是一個對象時,它只通過引用傳遞變量 – lumio
@ lumio通常允許在之後定義var,這樣我的問題。 – user310291
吊裝只適用於函數聲明而不適用於函數表達式:https://stackoverflow.com/q/336859/1169798 – Sirko