随笔分类 -  node

摘要:模板引擎基础概念 模板引擎是第三模块,让开发者以更加友好的方式拼接字符串,使项目代码更加清晰、更加易于维护。 art-template模板引擎 使用npm install art-template命令进行下载 使用const template = require('art-template')引入模 阅读全文
posted @ 2020-10-08 10:40 actorhuang 阅读(200) 评论(0) 推荐(0)
摘要:MongoDB增删改查操作 MongoDB数据库服务启动和关闭 net start mongodb net stop mongodb 数据库连接 先使用npm install mongoose安装mongoose依赖,之后使用mongoose提供的connect方法即可连接数据库。 const mo 阅读全文
posted @ 2020-10-05 10:08 actorhuang 阅读(136) 评论(0) 推荐(0)
摘要:Node.js异步编程 同步API,异步API 同步API:只有当前API执行完成后,才能继续执行下一个API console.log('before'); console.log('after'); 异步API:当前API的执行不会阻塞后续代码的执行 console.log('before'); 阅读全文
posted @ 2020-10-04 11:04 actorhuang 阅读(191) 评论(0) 推荐(0)
摘要:创建web服务器 const http = require("http"); //创建web服务器,app就是网站服务器对象 const app = http.createServer(); //当客户端有请求来的时候 app.on("request", (req, res) => { res.en 阅读全文
posted @ 2020-09-28 16:49 actorhuang 阅读(242) 评论(0) 推荐(0)
摘要:node第三方模块加载时出现XXX运行 提示错误:无法加载文件 C:\Users\gxf\AppData\Roaming\npm\XXX.ps1,因为在此系统上禁止运行脚本。 这是因为笔记本禁止运行脚本,解决方法 以管理员身份打开PowerShell 输入set-ExecutionPolicy Re 阅读全文
posted @ 2020-09-27 08:44 actorhuang 阅读(270) 评论(0) 推荐(0)
摘要:模块化开发 exports对象和module.exports对象的区别? exports对象一般情况下是和module.exports对象等价, 但是当 exports对象和module.exports对象指向的不是同一个对象时,以module.exports为准。 系统模块fs文件操作 读取文件 阅读全文
posted @ 2020-09-26 23:59 actorhuang 阅读(126) 评论(0) 推荐(0)