- 博客(7)
- 收藏
- 关注
原创 1.基础模块/1、global - 全局对象
global - 全局对象1. setInterval(callback, delay[, …args])callback: 当定时器到点时调用的函数。delay:调用 callback 之前等待的毫秒数。默认值: 1。...args :当调用 callback 时传入的可选参数。返回: 用于 [clearInterval()]2. setTimeout(callback[, delay[, …args]])callback :当定时器到点时调用的函数。delay:调用 callb
2021-01-31 15:48:09
189
3
原创 1.基础模块/3、path - 路径
path - 路径path 模块提供了一些实用工具,用于处理文件和目录的路径。 可以使用以下方式访问它:const path = require('path');1.path.basename(path[, ext])path <string>ext<string>可选的文件扩展名。返回:<string>path.basename() 方法会返回 path 的最后一部分。path.basename('/目录1/目录2/文件.html');// 返回
2021-01-31 15:44:06
431
2
原创 1.基础模块/4、fs - 文件系统
fs - 文件系统1 file system-文件读写读取文件(fs.readFile)写入文件(fs.writeFile)流程:引入fs模块 -> 调用方法 -> 异常捕获1.1、写入文件方法(异步、同步)1.1.1、fs.writeFile(file, data[, options], callback)file<string> | <Buffer> | <URL> | <integer> 文件名或文件描述符。data
2021-01-31 15:39:36
235
2
原创 1.基础模块/5、os - 操作系统
os - 操作系统os 模块提供了与操作系统相关的实用方法和属性。 使用方法如下:const os = require('os');1.os.platform()返回: <string>**返回标识操作系统平台的字符串。**可能的值有 'aix'、 'darwin'、 'freebsd'、 'linux'、 'openbsd'、 'sunos' 和 'win32'。const os = require('os');console.log(os.platform()); //
2021-01-31 15:26:42
434
1
原创 1.基础模块/6、url - URL
url - URLurl 模块用于处理与解析 URL。 使用方法如下:const url = require('url');属性1.url.href获取及设置序列化的 URL。const myURL = new URL('https://example.org/foo');console.log(myURL.href); // (获取) 打印 https://example.org/foomyURL.href = 'https://example.com/bar';c
2021-01-31 15:20:09
395
1
原创 1.基础模块/7、events - 事件触发器
Events - 事件触发器大多数 Node.js 核心 API 都是采用惯用的异步事件驱动架构(fs / http)所有能触发事件的对象都是 EventEmmitter 类的实例事件流程:引入模块 -> 创建 EventEmmitter 对象 -> 注册事件 -> 触发事件// 1 引入模块const EventEmitter = require('events');// 2 创建 MyEmmitter 类class MyEmitter extends EventEm
2021-01-31 15:09:37
347
5
原创 1.基础模块/8、http - HTTP
http - HTTP若要使用 HTTP 服务器和客户端,则可以 require('http')。最简单的一个应用:// 1 引入模块const http = require('http');// 2 创建服务器http.createServer((req, res) => { if(req.url === '/') { console.log(req.url); res.write('hello world!'); res.end
2021-01-31 15:06:16
286
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅