Get data from fs.readFile

前端 未结 15 2484
滥情空心
滥情空心 2020-11-22 15:38
var content;
fs.readFile(\'./Index.html\', function read(err, data) {
    if (err) {
        throw err;
    }
    content = data;
});
console.log(content);
         


        
15条回答
  •  春和景丽
    2020-11-22 16:27

    This line will work,

    const content = fs.readFileSync('./Index.html', 'utf8');
    console.log(content);
    

提交回复
热议问题