使用ReadStream方法延时读取文件
const fs = require('fs'); let file = fs.createReadStream("filenpath.js"); file.pause(); file.on("data", function(data) { console.log("读取到数据:"); console.log(data); }); setTimeout(function() { file.resume(); }, 3000);
const fs = require('fs'); let file = fs.createReadStream("filenpath.js"); file.pause(); file.on("data", function(data) { console.log("读取到数据:"); console.log(data); }); setTimeout(function() { file.resume(); }, 3000);