📜  节点加载文件 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:27.185000             🧑  作者: Mango

代码示例1
const fs = require("fs");

// __dirname means relative to script. Use "./data.txt" if you want it relative to execution path.
fs.readFile(__dirname + "/data.txt", (error, data) => {
    if(error) {
        throw error;
    }
    console.log(data.toString());
});