Instructionsfortheuseofthefs.readFilemethodinnode.js

Instructionsfortheuseofthefs.readFilemethodinnode.js
方法显示:

以异步方式读取文件内容。

不含粘性的内容编码条件,将是缓冲区的输出格式,如:

Grammar:

复制代码代码如下所示:

fs.readfile(filename,{编码},{回调(呃,数据)))
由于此方法属于fs模块,因此需要在使用之前引入FS模块(var FS =需求(fs))。

接收参数:

文件名,文件路径

选项选项对象,包括编码、编码格式,是可选的。

回调回调,传递2个参数异常错误和文件内容数据

实例uff1a

复制代码代码如下所示:

VaR FS =需要('fs);

fs.readfile(内容.txt,'utf-8功能(呃,数据){

如果(错误){

console.log(ERR);

其他{ }

console.log(数据);

}

})

tag:电脑软件InstructionsfortheusreadFilemethodinnodejs

相关内容