上一页 1 2 3 4 5 6 7 8 ··· 13 下一页
摘要: // 1. 导入需要的包 // 注意:导入的名称,就是装包时候的名称 const moment = require('moment') const dt = moment().format('YYYY-MM-DD HH:mm:ss') console.log(dt) 阅读全文
posted @ 2022-05-29 15:13 hi123hi159 阅读(94) 评论(0) 推荐(0)
摘要: // 1.1 导入 http 模块 const http = require('http') // 1.2 导入 fs 模块 const fs = require('fs') // 1.3 导入 path 模块 const path = require('path') // 2.1 创建 web 服 阅读全文
posted @ 2022-05-29 13:11 hi123hi159 阅读(108) 评论(0) 推荐(0)
摘要: const http = require('http') const server = http.createServer() server.on('request', (req, res) => { // 1. 获取请求的 url 地址 const url = req.url // 2. 设置默认 阅读全文
posted @ 2022-05-29 10:37 hi123hi159 阅读(38) 评论(0) 推荐(0)
摘要: // 1. 导入 http 模块 const http = require('http') // 2. 创建 web 服务器实例 const server = http.createServer() // 3. 为服务器实例绑定 request 事件,监听客户端的请求 server.on('requ 阅读全文
posted @ 2022-05-28 18:13 hi123hi159 阅读(55) 评论(0) 推荐(0)
摘要: // 1.1 导入 fs 模块 const fs = require('fs') // 1.2 导入 path 模块 const path = require('path') // 1.3 定义正则表达式,分别匹配 <style></style> 和 <script></script> 标签 con 阅读全文
posted @ 2022-05-28 15:46 hi123hi159 阅读(108) 评论(0) 推荐(0)
摘要: const path = require('path') // 这是文件的存放路径 const fpath = '/a/b/c/index.html' const fext = path.extname(fpath) console.log(fext) 阅读全文
posted @ 2022-05-28 15:02 hi123hi159 阅读(302) 评论(0) 推荐(0)
摘要: const path = require('path') // 定义文件的存放路径 const fpath = '/a/b/c/index.html' // const fullName = path.basename(fpath) // console.log(fullName) const na 阅读全文
posted @ 2022-05-28 14:42 hi123hi159 阅读(437) 评论(0) 推荐(0)
摘要: const path = require('path') const fs = require('fs') // 注意: ../ 会抵消前面的路径 // const pathStr = path.join('/a', '/b/c', '../../', './d', 'e') // console. 阅读全文
posted @ 2022-05-28 13:08 hi123hi159 阅读(643) 评论(0) 推荐(0)
摘要: const fs = require('fs') // __dirname 表示当前文件所处的目录 // console.log(__dirname) fs.readFile(__dirname + '/files/1.txt', 'utf8', function(err, dataStr) { i 阅读全文
posted @ 2022-05-27 15:46 hi123hi159 阅读(30) 评论(0) 推荐(0)
摘要: // 1. 导入 fs 模块 const fs = require('fs') // 2. 调用 fs.readFile() 读取文件的内容 fs.readFile('../素材/成绩.txt', 'utf8', function(err, dataStr) { // 3. 判断是否读取成功 if 阅读全文
posted @ 2022-05-27 15:25 hi123hi159 阅读(37) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 ··· 13 下一页