fs模块来读取本地文件系统中的文件
// 引入fs模块 const fs = require('fs');
// 读取文件 fs.readFile('path/to/file', 'utf-8', (err, data) => { if (err) throw err; console.log(data); });
// 读取文件的同步方法 const data = fs.readFileSync('path/to/file', 'utf-8'); console.log(data);
原文地址: https://www.cveoy.top/t/topic/cQ8S 著作权归作者所有。请勿转载和采集!