10 2022 档案

摘要:// express和node.js内置的http模块类似,是专门用来创建web服务器的 // express是一个第三方的包 // express是基于http内置模块封装出来的包,能提升开发效率 // web服务器分两种,api服务器和web服务器 const express = require 阅读全文 »
posted @ 2022-10-31 11:42 文采呱呱 阅读(21) 评论(0) 推荐(0) 编辑
摘要:// 装包完成后出现node_modules文件夹,是用来储存项目中的包,require引入的第三方包就是引用这里的,.package-lock记录每一个包的下载信息,包的名字,版本和下载地址 // 要下载指定版本包可以加@ 如:npm i dayjs@1.11.5 // npm i 包 核心依赖 阅读全文 »
posted @ 2022-10-31 09:59 文采呱呱 阅读(27) 评论(0) 推荐(0) 编辑
摘要:第三方模块和包是同一个概念 包是基于内置模块封装出来的 https://www.npmjs.com/ 全球最大包共享平台 https://registry.npmjs.org/ 下载包服务器 // 定义格式化时间的方法 function datatime(dtStr) { const dt = ne 阅读全文 »
posted @ 2022-10-26 18:18 文采呱呱 阅读(30) 评论(0) 推荐(0) 编辑
摘要:自定义模块 // console.log(module) // 自定义模块中,默认情况,module.exports = {} // 空对象 const name = 'zs' // 挂载方法 module.exports.usename = name // 挂载方法 module.exports. 阅读全文 »
posted @ 2022-10-25 17:45 文采呱呱 阅读(22) 评论(0) 推荐(0) 编辑
摘要://1 导入内置fs模块 const fs = require('fs') //2 导入path模块 const path = require('path') //3 导入http模块 const http = require('http') //4 创建web服务器 const server = 阅读全文 »
posted @ 2022-10-22 16:36 文采呱呱 阅读(20) 评论(0) 推荐(0) 编辑
摘要://http: // 1,导入http模块 const http = require('http') // 2,创建web实例 const server = http.createServer() // 3,为服务器绑定require事件 server.on('request',function(r 阅读全文 »
posted @ 2022-10-22 00:34 文采呱呱 阅读(22) 评论(0) 推荐(0) 编辑
摘要:// 导入 const fs = require('fs') const path = require('path') // 匹配正则表达式 // 样式 const regStyle = /<style>[\s\S]*<\/style>/ // js const regScript = /<scri 阅读全文 »
posted @ 2022-10-19 01:08 文采呱呱 阅读(25) 评论(0) 推荐(0) 编辑
摘要:1,拼接路径 const fs = require('fs') const path = require('path') fs.readFile(path.join(__dirname,'path'),'utf8',function(err,dataStr){ if(err){ return con 阅读全文 »
posted @ 2022-10-19 00:11 文采呱呱 阅读(36) 评论(0) 推荐(0) 编辑
摘要:1导入fs模块 const fs = require('fs') 2,读取文件内容 fs.readFlie(path,'utf8',function(err,dataStr){ console.log(err) console.log(' ') console.log(dataStr) }) 注:p 阅读全文 »
posted @ 2022-10-18 23:49 文采呱呱 阅读(34) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示