Node.js/JSON文件:修订间差异
来自康健生活
< Node.js
创建页面,内容为“<syntaxhighlight lang="javascript"> var file = path.join(__dirname, './analogdata/AuthoritativeGeneralHospital.js'); //文件路径,__dirname为当前运行js文…” |
无编辑摘要 |
||
| 第2行: | 第2行: | ||
var file = path.join(__dirname, './analogdata/AuthoritativeGeneralHospital.js'); //文件路径,__dirname为当前运行js文件的目录 | var file = path.join(__dirname, './analogdata/AuthoritativeGeneralHospital.js'); //文件路径,__dirname为当前运行js文件的目录 | ||
fs.readFile(file, 'utf-8', function(err, data) { | |||
if (err) { | |||
res.send('文件读取失败'); | |||
} else { | |||
res.send(JSON.stringify(data)); | |||
} | |||
});</syntaxhighlight> | |||
2020年6月28日 (日) 13:46的版本
var file = path.join(__dirname, './analogdata/AuthoritativeGeneralHospital.js'); //文件路径,__dirname为当前运行js文件的目录
fs.readFile(file, 'utf-8', function(err, data) {
if (err) {
res.send('文件读取失败');
} else {
res.send(JSON.stringify(data));
}
});
No categories