我这块代码自己刷新的时候 时好时坏;
这块和fs.readFileSync相比较优缺点,还希望前辈指点。
提示错误
: write after end
function router(req, res, next) {
let pets = {
list: false,
select: false
};
function renderList(data) {
res.render("./compents/exam_list_right", {
data: data["data"]
}, function(err, html) {
if (err) {
next(err);
return;
}
res.write("<script>document.getElementById('list').innerHTML ='" + html.replace(/\s/g, '') + "'</script>");
setEnd(pets,"list",res);
});
};
function renderLeft(data){
res.render("./compents/exam_list_left", {
data: data["data"]
}, function(err, html) {
if (err) {
next(err);
}
res.write("<script>document.getElementById('select').innerHTML ='" + html.replace(/\s/g, '') + "'</script>");
setEnd(pets,"select",res);
});
}
res.render("exam_list", {
title: "考试列表"
}, function(err, html) {
if (err) {
next(err);
return;
};
res.setHeader('content-type', 'text/html; charset=utf-8');
res.write(html);
});
userEvt.on("exam_list_right", renderList);
userEvt.on("exam_list_left", renderLeft);
Exam.getExamList({}, userEvt);
Exam.getExaType({}, userEvt);
}