随笔分类 -  node.js

摘要:定义 : global.变量名=‘xxxx’; 取出 : global.变量名 阅读全文
posted @ 2019-12-25 21:46 武卡卡 阅读(4769) 评论(0) 推荐(0) 编辑
摘要:1, 原因是因为:findOneAndUpdate()内部会使用findAndModify驱动,驱动即将被废弃,所以弹出警告!附上官方解释:Mongoose v5.5.8: Deprecation Warnings 2, 解决方法 在使用mongose时全局设置 mongoose.set('useF 阅读全文
posted @ 2019-12-08 00:14 武卡卡 阅读(2270) 评论(0) 推荐(2) 编辑
摘要:var multer = require('multer') var storage = multer.diskStorage({ destination: function (req, file, cb) { cb(null, 'uploads/') }, filename: function ( 阅读全文
posted @ 2019-11-22 23:43 武卡卡 阅读(668) 评论(0) 推荐(0) 编辑
摘要:一,只有在上传文件之前的钩子函数中才可以获得最初的文件(文件本身的二进制形式),用以以上传服务器。 还需要使用formdata来承载数据,便于接收 <template> <div> <el-upload action="http://localhost:3000/picture" :http-req 阅读全文
posted @ 2019-11-21 22:40 武卡卡 阅读(4503) 评论(0) 推荐(1) 编辑
摘要:const port = normalizePort(process.env.PORT || '3000'); const path = require('path'); const https = require('https'); const fs = require('fs'); const  阅读全文
posted @ 2019-11-06 15:19 武卡卡 阅读(2484) 评论(0) 推荐(0) 编辑
摘要:1,安装 cors 模块 : npm install cors 2,代码 : var express = require('express') var app = express() var cors = require('cors') app.use(cors()) 即可解决跨域问题 。(http 阅读全文
posted @ 2019-11-02 15:47 武卡卡 阅读(1487) 评论(0) 推荐(1) 编辑
摘要:1,cnpm i express -g 2, cnpm i express-generater -g 3, express - e 项目名 阅读全文
posted @ 2019-10-29 14:01 武卡卡 阅读(421) 评论(0) 推荐(0) 编辑
摘要:String(req.headers.authorization || '').split(' ').pop() 阅读全文
posted @ 2019-10-06 21:56 武卡卡 阅读(709) 评论(0) 推荐(1) 编辑
摘要:1,定义全局变量 app.set('name','八戒') 2,获取全局变量 app.get('name') 阅读全文
posted @ 2019-10-06 20:54 武卡卡 阅读(2039) 评论(0) 推荐(0) 编辑
摘要:原因 : 路由一定要暴露给外部使用 var express = require('express') var router = express.Router() router.get('/',(req,res)=>{ res.render('main/index.html') }) module.e 阅读全文
posted @ 2019-09-21 07:23 武卡卡 阅读(695) 评论(0) 推荐(0) 编辑
摘要:1,安装 moment模块 cnpm i moment --save 2,引入 var moment = require('moment'); 3,获取当前时间并格式化 var current_time = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss 阅读全文
posted @ 2019-09-19 22:39 武卡卡 阅读(6325) 评论(0) 推荐(1) 编辑
摘要:req.headers.cookie 阅读全文
posted @ 2019-09-13 22:32 武卡卡 阅读(401) 评论(0) 推荐(0) 编辑
摘要:一,服务器文件 app.js 。( 要使用路由的文件) const express = require('express') const app = express() const swig = require('swig') const bodyParser = require('body-par 阅读全文
posted @ 2019-09-12 22:20 武卡卡 阅读(251) 评论(0) 推荐(0) 编辑
摘要:使用cookies包需要注意:1,cookie中是不能有中文的,一旦有中文,就会报错2,cookie是通过 中间件的形式直接挂载到 req对象上的,那么cookies有的方法,req.cookies就有,一样的cookie是一个对象,需要JSON.stringify; 3,编码使用 encodeUR 阅读全文
posted @ 2019-06-11 14:36 武卡卡 阅读(552) 评论(0) 推荐(0) 编辑
摘要:var http = require("http"); var url = require("url"); var fs = require("fs"); var path = require("path"); http.createServer(function(req,res){ //得到用户的 阅读全文
posted @ 2019-06-05 08:26 武卡卡 阅读(539) 评论(0) 推荐(0) 编辑
摘要:ECMAScript 对于不同的环境(运行平台),设计结构,理念,使用方式大相径庭。 1,浏览器 :DOM BOM 2,NodeJS :FS,HTTP 内置模块 ; 第三方模块 ; 内置模块 3,桌面级应用及其他平台 : Window Mac 系统 及 其他操作平台 一,CommonJS 规范的由来 阅读全文
posted @ 2019-06-01 19:33 武卡卡 阅读(331) 评论(0) 推荐(0) 编辑
摘要:1,全局安装: npm install -g supervisor 2,使用: —————————————————————————————— nodemon 和 supervisor 流程一致。 阅读全文
posted @ 2019-06-01 16:59 武卡卡 阅读(758) 评论(0) 推荐(0) 编辑
摘要:一,前端渲染数据 的弊端 仿 apache 服务器与客户端的几次交互: 1,加载静态页面 2,加载静态资源 3,发送 ajax 请求 ,接收请求并处理返回 。 4,前端浏览器接收数据循环遍历。 存在的问题: 交互太多 /* * 使用 ajax 作请求的方式叫做 => 前端渲染数据,也叫客户端页面渲染 阅读全文
posted @ 2019-05-31 17:29 武卡卡 阅读(556) 评论(0) 推荐(0) 编辑
摘要:fs.readFile('.'+urls, function (err, data) { res.end(data) }); 阅读全文
posted @ 2019-05-27 10:39 武卡卡 阅读(177) 评论(0) 推荐(0) 编辑
摘要:nodejs =》 提供核心模块语法 node中的回调函数 都是异步 阅读全文
posted @ 2019-05-25 15:36 武卡卡 阅读(84) 评论(0) 推荐(0) 编辑

喜欢请打赏

扫描二维码打赏

支付宝打赏

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