随笔 - 326,  文章 - 0,  评论 - 0,  阅读 - 16万

随笔分类 -  nodeJs

Nodejs 响应中文乱码
摘要://获取前端请求过来的IP地址 let ip = (req.headers['x-real-ip'] || req.connection.remoteAddress).slice(7); //解决中文乱码 res.setHeader("content-Type",'text/plain;charse 阅读全文
posted @ 2023-02-24 14:52 文种玉 编辑
Nodejs Mysql 执行多条SQL语句
摘要:Nodejs Mysql 执行多条SQL语句 最近用 Nodejs + Express + Mysql 写接口碰到一个需要四表联查的接口。。。我特么只会连两张表啊~!网上百度了一波四表联查,由于我接口的数据相对比较复杂,果不其然,最终以凉凉告终,生活的压力最终迫使我向 SQL 妥协了。于是换了个思路 阅读全文
posted @ 2023-01-06 18:18 文种玉 编辑
express获取登录服务器的IP地址
摘要:let ip = (req.headers['x-real-ip'] || req.connection.remoteAddress).slice(7); 阅读全文
posted @ 2022-10-13 21:22 文种玉 编辑
执行 set-ExecutionPolicy RemoteSigned 失败解决方法
摘要:https://blog.csdn.net/lzfengquan/article/details/119413300 阅读全文
posted @ 2022-08-19 15:50 文种玉 编辑
nodejs对比java web目录
摘要:文件夹首字母小写 js~首字母大写 数据库连接模块 db ~~ BaseDao(放到Dao当中) services ~~ dao 控制层模块 router 阅读全文
posted @ 2022-01-15 14:58 文种玉 编辑
npm 淘宝镜像
摘要:```js npm config set registry https://registry.npm.taobao.org ``` 阅读全文
posted @ 2021-09-28 17:38 文种玉 编辑
express中的post请求处理
摘要:app.use(express.urlencoded({ extended: false })) app.use(express.json()) 测试 阅读全文
posted @ 2021-09-13 21:58 文种玉 编辑
十一.nodeJs解决跨域的问题
摘要:方式一 引入 npm i cors const app = express(); //在express下解决跨域 const cors = require('cors'); app.use(cors()); 方式二 res.setHeader("Access-Control-Allow-Origin 阅读全文
posted @ 2021-06-30 10:16 文种玉 编辑
二十.node.js自动启动浏览器
摘要://1.导包 const {exec} = require("child_process"); //2.启动浏览器 exec("start http://127.0.0.1:8888") 阅读全文
posted @ 2021-06-16 15:41 文种玉 编辑
二十五.关于浏览器的压缩
摘要:web页面如下 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" con 阅读全文
posted @ 2021-06-10 16:27 文种玉 编辑
二十四.浏览器的协商缓存与服务器的自启动
摘要:概述 协商缓存: 1. 客户端向服务端发送一个请求,请求相应的资源 2. 服务端向客户端发送一个响应,在响应头中携带两个关于缓存的信息,分别是 当前文件的唯一标识 (eTag)和 当前文件的最后一次修改时间(last-modified) 3. 客户端收到了响应文件和关于文件的缓存信息,并把缓存信息保 阅读全文
posted @ 2021-06-10 16:24 文种玉 编辑
二十三.浏览器的强制缓存与服务器的自动启动
摘要:web页面代码如下 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" c 阅读全文
posted @ 2021-06-10 16:20 文种玉 编辑
二十二.node使用用mysql连接池连接mysql数据库
摘要://使用连接池连接mysql const mysql = require("mysql"); //创建连接池 password:"123", let pool = mysql.createPool({ host:"127.0.0.1", post:"3306", user:"root", datab 阅读全文
posted @ 2021-06-09 20:45 文种玉 编辑
二十一.使用node.js连接mysql数据库
摘要:/** * 使用node连接mysql模块 */ //引入MySQL数据库 const mysql = require("mysql"); //创建一个mysql连接对象,连接是使用对象来连接数据库 let connection = mysql.createConnection({ host:"12 阅读全文
posted @ 2021-06-09 20:44 文种玉 编辑
八.ejs模板引擎的基本使用
摘要:创建 index.ejs <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport 阅读全文
posted @ 2021-06-09 20:22 文种玉 编辑
十.处理web页面向node服务器发送图片
摘要:图片请求案例 web页面如下 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewpo 阅读全文
posted @ 2021-06-09 20:12 文种玉 编辑
九.nodejs中ejs的基本使用
摘要:ejs 页面 作用,可以在页面当中编写 js 代码 页面中 页面的名称不是 html 后缀,而是 ejs 后缀 比如: <%- errData %> node中 需要安装 ejs npm i ejs 在node当中引入 ejs //引入ejs app.set("view engine","ejs") 阅读全文
posted @ 2021-06-09 19:45 文种玉 编辑
七.NodeJS与MongoDB实现简单的登录与注册
摘要:文件夹目录 连接数据库 const mongoose = require("mongoose"); mongoose.connect("mongodb://localhost:27017/school",{ useNewUrlParser: true, useUnifiedTopology: tru 阅读全文
posted @ 2021-06-09 19:39 文种玉 编辑
六.node.js连接MongoDB数据库
摘要:文件结构 一.使用mongoose连接MongoDB数据库 //引入mongoose数据库 const mongoose = require("mongoose"); //连接mongodb数据库 mongoose.connect("mongodb://localhost:27017/school" 阅读全文
posted @ 2021-06-08 20:57 文种玉 编辑
五.中间件的使用
摘要:应用中间件 /** * 应用中间件 * 1.应用中间件的作用一般用于对url的拦截 * 2.应用需要使用next对象中间件放行 * * 拓展:所有的中间件都使用了use,路由器也属于中间件的一种 */ const express = require("express"); const app = e 阅读全文
posted @ 2021-06-08 19:58 文种玉 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

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