《Node.js+Vue.js+MangoDB全栈开发实战》
随书源码下载地址:
链接:https://pan.baidu.com/s/1DQYgPZLmtJCIuDXs8gub_w?pwd=1127
提取码:1127
课件下载地址:
链接:https://pan.baidu.com/s/1M36y1xu-gIUidDxw38GlBg
提取码:1988
随书目录
目 录
第1章 Node.js和TypeScript基础·································································· 1
1.1 Node.js开发概述······································································································· 1
1.1.1 为什么要学习Node.js························································································ 1
1.1.2 什么是Node.js································································································· 2
1.1.3 Node.js特点···································································································· 3
1.1.4 var、let和const的区别······················································································ 3
1.1.5 开发工具········································································································ 4
1.2 Node运行环境搭建···································································································· 5
1.2.1 Node.js运行环境安装························································································ 5
1.2.2 Node环境安装失败解决办法··············································································· 6
1.2.3 代码有无分号的问题························································································· 6
1.3 Node.js快速入门······································································································· 7
1.3.1 Node.js的组成································································································· 7
1.3.2 Node.js基础语法······························································································ 7
1.3.3 Node.js全局对象global······················································································ 7
1.4 nvm简介、安装、使用······························································································· 8
1.5 VS Code的使用········································································································· 9
1.5.1 忽略node_module目录····················································································· 10
1.5.2 安装VS Code插件·························································································· 10
1.5.3 打开并运行项目······························································································ 12
1.5.4 VS Code配置································································································· 14
1.5.5 搜索············································································································· 15
第2章 模块加载及第三方包········································································· 17
2.1 Node.js模块化开发··································································································· 17
2.1.1 JavaScript开发弊端·························································································· 17
2.1.2 模块化·········································································································· 18
2.1.3 Node.js中模块化开发规范················································································· 18
2.1.4 exports和module.exports的区别········································································· 20
2.1.5 require优先从缓存加载····················································································· 21
2.2 系统模块················································································································ 22
2.2.1 什么是系统模块······························································································ 22
2.2.2 系统模块fs文件操作······················································································· 22
2.2.3 系统模块path路径操作···················································································· 24
2.2.4 相对路径VS绝对路径····················································································· 24
2.3 第三方模块············································································································· 25
2.3.1 什么是第三方模块··························································································· 25
2.3.2 获取第三方模块······························································································ 25
2.3.3 npm············································································································· 25
2.3.4 yarn············································································································· 26
2.3.5 yarn和npm的区别·························································································· 27
2.3.6 第三方模块nrm······························································································ 28
2.3.7 第三方模块nodemon························································································ 29
2.3.8 第三方模块 gulp····························································································· 29
2.3.9 npx·············································································································· 36
2.4 package.json文件······································································································ 37
2.4.1 node_modules目录的问题·················································································· 37
2.4.2 package.json文件的作用···················································································· 38
2.4.3 项目依赖和开发依赖························································································ 38
2.4.4 package.json文件各个选项含义··········································································· 38
2.4.5 package-lock.json文件的作用·············································································· 40
2.4.6 yarn.lock的作用······························································································ 40
2.5 Node.js中模块的加载机制·························································································· 41
2.5.1 模块查找规则:当模块拥有路径但没有后缀时······················································· 41
2.5.2 模块查找规则:当模块没有路径且没有后缀时······················································· 41
第3章 HTTP及Node异步编程···································································· 44
3.1 C/S、B/S软件体系结构分析······················································································· 44
3.2 服务器端基础概念···································································································· 45
3.2.1 网站的组成···································································································· 45
3.2.2 网站服务器···································································································· 46
3.2.3 IP地址········································································································· 46
3.2.4 域名············································································································· 47
3.2.5 端口············································································································· 48
3.2.6 URL············································································································· 49
3.2.7 客户端和服务器端··························································································· 49
3.3 创建web服务器······································································································ 49
3.4 HTTP协议·············································································································· 51
3.4.1 HTTP协议的概念··························································································· 51
3.4.2 报文············································································································· 51
3.4.3 请求报文······································································································· 52
3.4.4 响应报文······································································································· 57
3.5 HTTP请求与响应处理······························································································· 58
3.5.1 请求参数······································································································· 58
3.5.2 GET请求参数································································································ 58
3.5.3 POST请求参数······························································································ 59
3.5.4 路由············································································································· 60
3.5.5 静态资源······································································································· 61
3.5.6 动态资源······································································································· 62
3.5.7 客户端请求方式······························································································ 63
3.6 Node.js异步编程······································································································ 64
3.6.1 同步API,异步API························································································ 64
3.6.2 同步API,异步API的区别·············································································· 64
3.6.3 回调函数······································································································· 66
3.6.4 Node.js中的异步API······················································································· 66
3.6.5 Promise········································································································· 68
3.6.6 异步函数async和await···················································································· 70
第4章 MongoDB数据库············································································ 72
4.1 数据库概述············································································································· 72
4.1.1 为什么要使用数据库························································································ 72
4.1.2 什么是数据库································································································· 72
4.1.3 MongoDB数据库相关概念················································································ 73
4.2 MongoDB数据库环境搭建························································································· 75
4.2.1 MongoDB数据库下载安装················································································ 75
4.2.2 启动MongoDB······························································································· 78
4.3 MongoDB操作········································································································ 78
4.3.1 MongoDB的Shell操作···················································································· 78
4.3.2 MongoDB可视化软件······················································································ 83
4.3.3 MongoDB导入导出数据··················································································· 85
4.4 MongoDB索引介绍及数据库命令操作·········································································· 86
4.4.1 创建简单索引································································································· 86
4.4.2 唯一索引······································································································· 88
4.4.3 删除重复值···································································································· 88
4.4.4 Hint············································································································· 88
4.4.5 Expain·········································································································· 88
4.4.6 索引管理······································································································· 90
4.5 MongoDB备份与恢复······························································································· 91
4.5.1 MongoDB数据库备份······················································································ 91
4.5.2 MongoDB数据库恢复······················································································ 91
4.6 Mongoose数据库连接······························································································· 93
4.7 Mongoose增删改查操作···························································································· 93
4.7.1 创建数据库···································································································· 94
4.7.2 创建集合······································································································· 95
4.7.3 创建文档······································································································· 95
4.7.4 查询文档······································································································· 96
4.7.5 删除文档····································································································· 101
4.7.6 更新文档····································································································· 101
4.7.7 mongoose验证······························································································ 102
4.7.8 集合关联····································································································· 103
第5章 art-template模板引擎······································································ 106
5.1 模板引擎的基础概念······························································································· 106
5.1.1 模板引擎····································································································· 106
5.1.2 art-template简介····························································································· 107
5.2 模板引擎语法········································································································ 110
5.2.1 输出··········································································································· 110
5.2.2 原文输出····································································································· 110
5.2.3 条件判断····································································································· 110
5.2.4 循环··········································································································· 110
5.2.5 子模板········································································································ 111
5.2.6 模板继承····································································································· 111
5.2.7 模板配置····································································································· 112
5.3 案例——用户管理·································································································· 113
5.3.1 案例介绍····································································································· 113
5.3.2 操作步骤····································································································· 115
第6章 Express框架················································································ 125
6.1 Express框架简介···································································································· 125
6.1.1 Express框架是什么························································································ 125
6.1.2 Express框架特性··························································································· 125
6.2 中间件················································································································· 126
6.2.1 什么是中间件······························································································· 126
6.2.2 app.use中间件用法························································································ 127
6.2.3 中间件应用·································································································· 128
6.2.4 错误处理中间件···························································································· 129
6.2.5 捕获异常····································································································· 130
6.3 Express请求处理···································································································· 131
6.3.1 构建路由····································································································· 131
6.3.2 构建模块化路由···························································································· 132
6.3.3 GET参数的获取···························································································· 132
6.3.4 POST参数的获取·························································································· 133
6.3.5 Express路由参数··························································································· 134
6.3.6 静态资源处理······························································································· 135
6.4 express-art-template模板引擎······················································································ 135
6.5 express-session········································································································ 136
6.5.1 Session简单介绍··························································································· 136
6.5.2 express-session的使用····················································································· 136
6.5.3 express-session 的常用参数·············································································· 137
第7章 TypeScript介绍············································································ 138
7.1 TypeScript基础······································································································· 138
7.1.1 TypeScript简介····························································································· 138
7.1.2 TypeScript的特点·························································································· 139
7.1.3 安装TypeScript····························································································· 139
7.1.4 ts和js的区别······························································································· 140
7.1.5 编写TS程序································································································ 140
7.1.6 手动编译代码······························································································· 141
7.1.7 VS Code自动编译························································································· 142
7.1.8 类型注解····································································································· 143
7.1.9 vite快速创建ts开发环境················································································· 144
7.2 基础类型·············································································································· 145
7.2.1 布尔值········································································································ 145
7.2.2 数字··········································································································· 146
7.2.3 字符串········································································································ 146
7.2.4 undefined和null···························································································· 146
7.2.5 数组··········································································································· 147
7.2.6 元组Tuple···································································································· 147
7.2.7 枚举··········································································································· 147
7.2.8 any············································································································· 148
7.2.9 void············································································································ 148
7.2.10 Never········································································································ 149
7.2.11 Object········································································································ 149
7.2.12 联合类型···································································································· 149
7.2.13 类型断言···································································································· 150
7.2.14 类型推断···································································································· 150
7.3 接口···················································································································· 151
7.3.1 接口初探····································································································· 151
7.3.2 可选属性?···································································································· 151
7.3.3 只读属性readonly·························································································· 152
7.3.4 函数类型····································································································· 152
7.3.5 类类型········································································································ 153
7.4 类······················································································································· 154
7.4.1 基本示例····································································································· 154
7.4.2 继承··········································································································· 154
7.4.3 公共,私有与受保护的修饰符·········································································· 157
7.4.4 readonly 修饰符···························································································· 158
7.4.5 存取器········································································································ 158
7.4.6 静态属性····································································································· 159
7.4.7 抽象类········································································································ 160
7.5 函数···················································································································· 160
7.5.1 基本示例····································································································· 160
7.5.2 函数类型····································································································· 161
7.5.3 可选参数和默认参数······················································································ 161
7.5.4 剩余参数····································································································· 161
7.5.5 函数重载····································································································· 162
7.6 泛型···················································································································· 162
7.6.1 泛型引入····································································································· 163
7.6.2 使用函数泛型······························································································· 163
7.6.3 多个泛型参数的函数······················································································ 163
7.6.4 泛型接口····································································································· 163
7.6.5 泛型类········································································································ 164
7.6.6 泛型约束····································································································· 165
7.7 声明文件和内置对象······························································································· 165
7.7.1 声明文件····································································································· 165
7.7.2 内置对象····································································································· 166
第8章 文章管理系统··············································································· 168
8.1 项目环境搭建········································································································ 168
8.1.1 项目介绍····································································································· 168
8.1.2 项目框架搭建······························································································· 169
8.2 项目功能实现········································································································ 176
8.2.1 登录··········································································································· 176
8.2.2 文章管理····································································································· 191
8.2.3 用户管理····································································································· 203
8.2.4 网站首页文章展示························································································· 207
8.2.5 文章评论····································································································· 208
8.2.6 访问权限控制······························································································· 210
8.3 项目源码和运行····································································································· 211
第9章 后台管理系统··············································································· 213
9.1 项目介绍·············································································································· 213
9.1.1 项目介绍····································································································· 213
9.1.2 技术选型····································································································· 215
9.2 项目搭建·············································································································· 216
9.3 后端项目搭建········································································································ 217
9.3.1 搭建node web服务器项目··············································································· 217
9.3.2 数据库初始化······························································································· 226
9.3.3 启动web服务器···························································································· 227
9.3.4 接口测试····································································································· 227
9.4 前端项目搭建········································································································ 228
9.4.1 基础目录结构构建························································································· 228
9.4.2 配置pinia····································································································· 232
9.4.3 准备路由环境······························································································· 234
9.4.4 封装接口请求······························································································· 234
9.4.5 搭建主界面·································································································· 237
9.4.6 配置路由····································································································· 243
9.4.7 构建系统后台首页························································································· 246
9.4.8 用户列表····································································································· 248
9.4.9 新增/编辑用户······························································································ 253
9.4.10 配置代理···································································································· 258
9.5 项目运行·············································································································· 258
标签:Node,Vue,MongoDB,js,7.2,模块,9.4 From: https://www.cnblogs.com/jiekzou/p/18169091