01 2021 档案

摘要:目录概览: app.js /* koa 静态资源中间件/静态web服务 koa-static 的使用: 1、安装 : npm i --save koa-static 2、引入 : const static = require("koa-static") 3、配置中间件 : app.use(stati 阅读全文
posted @ 2021-01-26 16:12 半遮 阅读(470) 评论(0) 推荐(0) 编辑
摘要:目录概览: views/public/header.ejs <h1>这是public里面的头部</h1> views/news.ejs <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewpor 阅读全文
posted @ 2021-01-26 11:20 半遮 阅读(200) 评论(0) 推荐(0) 编辑
摘要:/* Koa 的中间件,无论写在前面还是后面,都会先执行中间件的代码, */ /* Koa 路由 get 传值 在 Koa2 中 GET 传值通过request接收,但是接收的方法有两种: query 和 querystring query : 返回的是格式化好的参数对象 querystring : 阅读全文
posted @ 2021-01-23 12:28 半遮 阅读(238) 评论(0) 推荐(0) 编辑
摘要:/* Koa 的中间件,无论写在前面还是后面,都会先执行中间件的代码, */ /* Koa 路由 get 传值 在 Koa2 中 GET 传值通过request接收,但是接收的方法有两种: query 和 querystring query : 返回的是格式化好的参数对象 querystring : 阅读全文
posted @ 2021-01-23 12:26 半遮 阅读(557) 评论(0) 推荐(0) 编辑
摘要:/* Koa 路由 get 传值 在 Koa2 中 GET 传值通过request接收,但是接收的方法有两种: query 和 querystring query : 返回的是格式化好的参数对象 querystring : 返回的是请求字符串 */ // 引入模块 const Koa = requi 阅读全文
posted @ 2021-01-23 12:24 半遮 阅读(144) 评论(0) 推荐(0) 编辑
摘要:/* Koa 路由 get 传值 在 Koa2 中 GET 传值通过request接收,但是接收的方法有两种: query 和 querystring query : 返回的是格式化好的参数对象 querystring : 返回的是请求字符串 */ // 引入模块 const Koa = requi 阅读全文
posted @ 2021-01-23 12:21 半遮 阅读(108) 评论(0) 推荐(0) 编辑
摘要:koa2 的 中文文档: https://www.itying.com/koa/article-index-id-60.html /* Koa 路由 get 传值 在 Koa2 中 GET 传值通过request接收,但是接收的方法有两种: query 和 querystring query : 返 阅读全文
posted @ 2021-01-22 00:22 半遮 阅读(773) 评论(0) 推荐(0) 编辑
摘要:// async 是让方法变成异步 // await 是等待该代码执行完成后(会阻塞程序执行),再往下执行。 // /** // 普通方法 function getData() { return "这是一个数据"; } console.log(getData()); //返回: 这是一个数据 */ 阅读全文
posted @ 2021-01-20 17:55 半遮 阅读(156) 评论(0) 推荐(0) 编辑
摘要:参考:https://www.cnblogs.com/LO-ME/p/10883032.html 阅读全文
posted @ 2021-01-20 14:53 半遮 阅读(103) 评论(0) 推荐(0) 编辑
摘要:// ES6 回顾: // 1、模板字符串 /* var name = "张三"; var age = 20; console.log(name + "已经" + age + "岁了!"); //常规的拼接写法 console.log(`${name}已经${age}岁啦`);//ES6的模板字符串 阅读全文
posted @ 2021-01-20 13:27 半遮 阅读(57) 评论(0) 推荐(0) 编辑
摘要:./model/db.js // 引入mongoose const mongoose = require("mongoose"); //解决index索引引起的弃用提醒:(node:13616) DeprecationWarning: collection.ensureIndex is deprec 阅读全文
posted @ 2021-01-18 19:23 半遮 阅读(156) 评论(0) 推荐(0) 编辑
摘要:./model/db.js // 引入mongoose const mongoose = require("mongoose"); //解决index索引引起的弃用提醒:(node:13616) DeprecationWarning: collection.ensureIndex is deprec 阅读全文
posted @ 2021-01-18 12:49 半遮 阅读(367) 评论(0) 推荐(0) 编辑
摘要:Model.deleteMany() Model.deleteOne() Model.find() Model.findById() Model.findByIdAndDelete() Model.findByIdAndRemove() Model.findByIdAndUpdate() Model 阅读全文
posted @ 2021-01-17 23:46 半遮 阅读(134) 评论(0) 推荐(0) 编辑
摘要:./model/db.js // 引入mongoose const mongoose = require("mongoose"); //解决index索引引起的弃用提醒:(node:13616) DeprecationWarning: collection.ensureIndex is deprec 阅读全文
posted @ 2021-01-17 23:31 半遮 阅读(278) 评论(0) 推荐(0) 编辑
摘要:// es5 function person() { console.log("1:pe1"); //实例化一次就会执行一遍该函数, this.run = function () { //实例方法,需要实例化后才能通过实例化对象来调用 console.log("2:run"); console.lo 阅读全文
posted @ 2021-01-17 22:48 半遮 阅读(261) 评论(0) 推荐(0) 编辑
摘要:./model/user.js /* mongoose 的自定义修饰符: Getters 与 setters 除了mongoose内置修饰符以外,还可以通过 set (建议使用) 修饰符,对增加数据的时,对数据进行格式化; 也可以通过 get(不建议使用)在 实例获取数据 的时候 对 实例数据 进行 阅读全文
posted @ 2021-01-12 11:57 半遮 阅读(141) 评论(0) 推荐(0) 编辑
摘要:// mongoose 默认参数、 mongoose 模块化 、 mongoose 性能疑问 // mongoose 默认参数 :增加数据时候,如果不传入数据,会使用默认配置的数据 const mongoose = require("mongoose"); mongoose.connect("mon 阅读全文
posted @ 2021-01-07 16:52 半遮 阅读(176) 评论(0) 推荐(0) 编辑
摘要:mongoose01.js : /* mongoose 的使用: 1、npm 安装 mongoose : npm i mongoose --save ; 2、引入 mongoose 并连接数据库: const mongoose = require('mongoose'); mongoose.conn 阅读全文
posted @ 2021-01-06 14:56 半遮 阅读(275) 评论(0) 推荐(0) 编辑
摘要:多文件上传: views/admin/user/add.html : <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, i 阅读全文
posted @ 2021-01-05 18:05 半遮 阅读(492) 评论(0) 推荐(0) 编辑
摘要:单文件上传 目录: nav/add.html : <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-sca 阅读全文
posted @ 2021-01-05 12:30 半遮 阅读(148) 评论(0) 推荐(0) 编辑

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