node:文件写入数据(readFile、writeFile),覆盖与增量两种模式
const fs = require('fs');
const data = {
name: 'zs'
};
const wirte = (data) => {
return data
}
fs.readFile('./', 'utf8', function(err, info) {
if (err) console.log('文件读取失败!' + err.message)
console.log(`文件读取成功!`,info)
fs.writeFile("./", `${info};const time${new Date().getTime()} = ${JSON.stringify(wirte(data))}`, err => {
if (err) console.log('文件写入失败!' + err.message)
console.log(`文件写入成功!${__dirname}\\`)
})
});