1812b-lzy3 中文文档教程
fs算法
打印文本内容
let fs = require("fs");
function fun(url) {
return new Promise((resolve, reject) => {
fs.readFile(url, "utf-8", (err, data) => {
if (err) {
reject(err);
return;
} else {
resolve(data)
}
})
})
}
fun("1.txt").then(data1 => {
console.log(data1)
return fun("2.txt");
}).then(data2 => {
console.log(data2)
return fun("3.txt");
})