Get data from fs.readFile

前端 未结 15 2529
滥情空心
滥情空心 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:29

    function readContent(callback) {
        fs.readFile("./Index.html", function (err, content) {
            if (err) return callback(err)
            callback(null, content)
        })
    }
    
    readContent(function (err, content) {
        console.log(content)
    })
    

提交回复
热议问题