摘要: // 引入 mongoose 第三方模块 用来操作数据库 const mongoose = require('mongoose'); // 数据库连接 mongoose.connect('mongodb://localhost/playground', { useNewUrlParser: true 阅读全文
posted @ 2020-06-10 21:41 EricBlog 阅读(111) 评论(0) 推荐(0)
摘要: // 引入 mongoose 第三方模块 用来操作数据库 const mongoose = require('mongoose'); // 数据库连接 mongoose.connect('mongodb://localhost/playground', { useNewUrlParser: true 阅读全文
posted @ 2020-06-10 20:37 EricBlog 阅读(346) 评论(0) 推荐(0)
摘要: // 更新操作 更新一个 // User.updateOne({ // name: '李四' // }, { name: '李狗蛋', age: 98 }).then(result => console.log(result)) // 更新 所有 // User.updateMany({}, { a 阅读全文
posted @ 2020-06-10 20:22 EricBlog 阅读(140) 评论(0) 推荐(0)
摘要: // 引入 mongoose 第三方模块 用来操作数据库 const mongoose = require('mongoose'); // 数据库连接 mongoose.connect('mongodb://localhost/playground', { useNewUrlParser: true 阅读全文
posted @ 2020-06-10 20:13 EricBlog 阅读(134) 评论(0) 推荐(0)
摘要: // 查询所有用户集合中的文档 // User.find().then(result => console.log(result)); // 查询一条 // User.find({ // _id: '5c09f294aeb04b22f8460969' // }).then(result => con 阅读全文
posted @ 2020-06-10 20:06 EricBlog 阅读(183) 评论(0) 推荐(0)
摘要: 导入成功 阅读全文
posted @ 2020-06-10 19:39 EricBlog 阅读(139) 评论(0) 推荐(0)
摘要: // 引入 mongoose 第三方模块 用来操作数据库 const mongoose = require('mongoose'); // 数据库连接 mongoose.connect('mongodb://localhost/playground', { useNewUrlParser: true 阅读全文
posted @ 2020-06-10 19:32 EricBlog 阅读(422) 评论(0) 推荐(0)
摘要: 加上这两句 不会报错 阅读全文
posted @ 2020-06-10 18:16 EricBlog 阅读(146) 评论(0) 推荐(0)
摘要: const fs = require('fs'); // fs.readFile('./1.txt', 'utf8', (err, restult1) => { // console.log(restult1); // fs.readFile('./2.txt', 'utf8', (err, res 阅读全文
posted @ 2020-06-10 17:35 EricBlog 阅读(321) 评论(0) 推荐(0)
摘要: 异步API 无法通过返回值拿到 回调函数 阅读全文
posted @ 2020-06-10 16:12 EricBlog 阅读(979) 评论(0) 推荐(0)
摘要: inpm install mime const mime = require('mime'); 指定返回资源的类型 mime 可以自动区分页面文件 const http = require('http'); const url = require('url'); const app = http.c 阅读全文
posted @ 2020-06-10 15:17 EricBlog 阅读(379) 评论(0) 推荐(0)
摘要: // 1 引入系统模块 const http = require('http'); const url = require('url'); // 2 创建网站服务 const app = http.createServer(); // 3为网站服务器对象添加请求事件 app.on('request' 阅读全文
posted @ 2020-06-10 14:33 EricBlog 阅读(102) 评论(0) 推荐(0)
摘要: // 创建服务器模块 const http = require('http'); // app 对象就是网站服务器对象 const app = http.createServer(); // 当有请求的时候 app.on('request', (req, res) => { // 获取请求方式 // 阅读全文
posted @ 2020-06-10 14:07 EricBlog 阅读(242) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-06-10 12:07 EricBlog 阅读(78) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-06-10 11:52 EricBlog 阅读(154) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-06-10 11:48 EricBlog 阅读(148) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-06-10 11:23 EricBlog 阅读(83) 评论(0) 推荐(0)
摘要: 复制给别人项目,不需要复制 node_modules 文件, 别人收到文件,npm install 就可以 运行项目了 阅读全文
posted @ 2020-06-10 11:01 EricBlog 阅读(613) 评论(0) 推荐(0)
摘要: // 构建任务 gulp.task('default', ['htmlmin', 'cssmin', 'jsmin', 'copy']); 阅读全文
posted @ 2020-06-10 10:48 EricBlog 阅读(755) 评论(0) 推荐(0)
摘要: 如需卸载:cnpm uninstall gulp -g 如果有安装失败依赖,降低node版本为11 全局安装 gulp:npm install --global gulp 作为项目的开发依赖(devDependencies)安装:npm install --save-dev gulp 这时候会gul 阅读全文
posted @ 2020-06-10 10:46 EricBlog 阅读(1457) 评论(0) 推荐(0)
摘要: // 复制文件夹 gulp.task('copy', () => { gulp.src('./src/images/*') .pipe(gulp.dest('dist/images')); gulp.src('./src/lib/*') .pipe(gulp.dest('dist/lib')) }) 阅读全文
posted @ 2020-06-10 10:20 EricBlog 阅读(1138) 评论(2) 推荐(0)
摘要: npm install --save-dev gulp-babel @babel/core @babel/preset-env // 暂时用下面这个 npm install gulp-babel @babel/core @babel/preset-env const babel = require( 阅读全文
posted @ 2020-06-10 10:13 EricBlog 阅读(686) 评论(0) 推荐(0)
摘要: npm install gulp-less const less = require('gulp-less'); // css任务 // 1.less 语法转换 // 2.css代码压缩 gulp.task('cssmin', () => { gulp.src('./src/css/*.less') 阅读全文
posted @ 2020-06-10 09:48 EricBlog 阅读(337) 评论(0) 推荐(0)
摘要: npm install gulp-file-include 引入 const fileinclude = require('gulp-file-include') src 目录下 新建 common 目录 把公共部分剪切到 header.html 里面 引入 公共部分 多了 头部框架开始 代表成功 阅读全文
posted @ 2020-06-10 09:23 EricBlog 阅读(264) 评论(0) 推荐(0)
摘要: // 1. html文件中的代码压缩操作 // 安装 npm install gulp-htmlmin''' 引入 const htmlmin = require('gulp-htmlmin'); // 创建任务 gulp.task('htmlmin', () => { // * 代表文件下的所有h 阅读全文
posted @ 2020-06-10 09:08 EricBlog 阅读(264) 评论(0) 推荐(0)