摘要: 阅读全文
posted @ 2020-06-19 23:07 17135131xjt 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-06-19 23:05 17135131xjt 阅读(1) 评论(0) 推荐(0) 编辑
摘要: // 1、加载http核心模块 var http = require('http'); // 2、使用http.createServer()方法创建一个web服务器 var server = http.createServer(); // 3、服务器要干嘛? // 提供服务:对数据的服务 // 发请 阅读全文
posted @ 2020-06-19 21:16 17135131xjt 阅读(6) 评论(0) 推荐(0) 编辑
摘要: // node中 专门提供了一个核心模块:http // http这个模块的职责就是帮你创建编写服务器 // 1、加载 http核心模块 var http = require('http'); // 2、使用createServer()方法创建一个web服务器 // 返回一个Server实例 var 阅读全文
posted @ 2020-06-19 19:31 17135131xjt 阅读(183) 评论(0) 推荐(0) 编辑
摘要: ###node环境下读文件 读文件时,需要读数据,所以function的参数中不仅有error还有data,如果读取失败,data为udfind,这时data.toString()毫无意义会报错 所以可以加入判断,如果error(error时,打印error输出报错对象)则打印读取失败并且跳出,不然 阅读全文
posted @ 2020-06-19 17:40 17135131xjt 阅读(141) 评论(0) 推荐(0) 编辑
摘要: var fs = require('fs'); fs.readFile('a.txt', function (error, data) { console.log(data.toString()); }) 阅读全文
posted @ 2020-06-19 14:47 17135131xjt 阅读(285) 评论(0) 推荐(0) 编辑
摘要: ![](https://img2020.cnblogs.com/blog/1968139/202006/1968139-20200619132004380-247143571.png) 阅读全文
posted @ 2020-06-19 14:24 17135131xjt 阅读(209) 评论(0) 推荐(1) 编辑