摘要:
1,连接数据库: cmd 进入终端,输入 mongo 输入 show dbs 可以看到所以的数据库: 刚开始会有这三个数据库 2,创建数据库(加入创建一个 hello 的数据库) 需要 往 hello 数据库的 user 集合中插入一条数据,数据库才真正创建成功 3,插入(增加)数据 db.user 阅读全文
posted @ 2021-02-02 00:28
shanlu
阅读(180)
评论(0)
推荐(0)
摘要:
1,explain explain 会帮助你获得查询方面诸多有用的信息。只要对游标调用该方法,就可以得到查询细节。explain 会返回一个文档,而不是游标本身 > use hello switched to db hello > db.user.find().explain("executionS 阅读全文
posted @ 2021-02-02 00:26
shanlu
阅读(92)
评论(0)
推荐(0)
摘要:
1,创建超级管理用户: > show dbs admin 0.000GB config 0.000GB local 0.000GB > use admin switched to db admin > db.createUser({ ... user:"admin", ... pwd:"123", 阅读全文
posted @ 2021-02-02 00:25
shanlu
阅读(108)
评论(0)
推荐(0)
摘要:
fs.stat 检测是文件还是目录 const fs = require('fs') fs.stat('./testdir',(err,data)=>{ if(err){ console.log(err) return } console.log(`是文件:${data.isFile()}`) co 阅读全文
posted @ 2021-02-02 00:24
shanlu
阅读(149)
评论(0)
推荐(0)
摘要:
assets文件夹下面有images css js目录 以及index.html , 找出 wwwroot目录下面的所有的目录,然后放在一个数组中 const fs = require('fs') var path = './assets' var dirArr=[] fs.readdir(path 阅读全文
posted @ 2021-02-02 00:23
shanlu
阅读(108)
评论(0)
推荐(0)
摘要:
定义一个 add 模块并暴露出去: function add(a,b){ return a+b } exports.add = add; 测试文件中引入这个模块,并调用这个模块中的方法: const util = require('./util/add') console.log(util); // 阅读全文
posted @ 2021-02-02 00:22
shanlu
阅读(181)
评论(0)
推荐(0)
摘要:
url.parse() : 解析 url const url = require('url') const api = "http://www.baidu.com?name=jack&sex=1" const _url=url.parse(api) console.log(_url) 添加 true 阅读全文
posted @ 2021-02-02 00:21
shanlu
阅读(76)
评论(0)
推荐(0)
摘要:
VSCode 中,输入 node-http-server,自动创建一个 web 服务 //node-http-server var http = require('http'); http.createServer(function (request, response) { response.wr 阅读全文
posted @ 2021-02-02 00:19
shanlu
阅读(91)
评论(0)
推荐(0)
摘要:
WEB服务器: 一般指网站服务器,是指驻留在因特网上某种类型计算机的程序,可以向浏览器等Web 客户端提供文档,也可以放置网站文件让全世界浏览,还可以放置数据文件,让全世界下载,目前最主流的Web服务器有 Apache,Nginx,IIS等。 NodeJS 创建一个WEB服务器, 可以让我们访问We 阅读全文
posted @ 2021-02-02 00:18
shanlu
阅读(389)
评论(0)
推荐(0)
摘要:
路由(Routing)是由一个URI(或者叫路径)和一个特定的HTTP 方法(GET、POST 等)组成的,涉及到应用如何响应客户端对某个网站节点的访问。路由指的就是针对不同请求的URL,处理不同的业务逻辑。 route.js const http = require('http'); const 阅读全文
posted @ 2021-02-02 00:17
shanlu
阅读(118)
评论(0)
推荐(0)
摘要:
https://www.npmjs.com/package/ejs 安装:npm install ejs --save app.js const http = require('http'); const url = require('url') const ejs = require('ejs') 阅读全文
posted @ 2021-02-02 00:16
shanlu
阅读(115)
评论(0)
推荐(0)
摘要:
获取 get 传值: get 方式获取登录表单: 获取 post 传值: const http = require('http'); const url = require('url') const ejs = require('ejs') const staticWeb = require('./ 阅读全文
posted @ 2021-02-02 00:14
shanlu
阅读(470)
评论(0)
推荐(0)
摘要:
1,模块化方式封装路由 Route.js const staticWeb = require('./web') const app={ static:function(req,res,staticPath){ //创建静态Web服务 staticWeb(req, res, './static') } 阅读全文
posted @ 2021-02-02 00:13
shanlu
阅读(78)
评论(0)
推荐(0)
摘要:
Express:https://www.expressjs.com.cn/ express路由: var express = require('express') var app = express() app.get("/", function (req, res) { res.send('hel 阅读全文
posted @ 2021-02-02 00:11
shanlu
阅读(543)
评论(0)
推荐(0)
摘要:
Hook 是 React 16.8 的新增特性,它可以让你在不编写 class 的情况下 使用 state 以及其他的React 特性。 React Hooks 编写形式对比: class 写法: import React, { Component } from 'react' export def 阅读全文
posted @ 2021-02-02 00:09
shanlu
阅读(90)
评论(0)
推荐(0)
摘要:
useState 是 react 自带的一个 hook 函数,它的作用是用来声明状态变量 ①声明: const [ count , setCount ] = useState(0); 这种方法是 ES6 语法中的数组解构。useState 这个函数接收的参数是状态的初始值,它返回一个数组,这个数组的 阅读全文
posted @ 2021-02-02 00:08
shanlu
阅读(115)
评论(0)
推荐(0)
摘要:
在用 Class 制作组件时,经常会用生命周期函数,来处理一些额外的事情(副作用:和函数业务主逻辑关联不大,特定时间或事件中执行的动作,比如Ajax 请求后端数据,添加登录监听和取消登录,手动修改DOM等等 ),在 React Hooks 中也需要这样类似的生命周期函数,比如在每次状态更新时执行,这 阅读全文
posted @ 2021-02-02 00:07
shanlu
阅读(126)
评论(0)
推荐(0)
摘要:
在用类声明 组件时,父子组件的传值是通过组件属性 props 进行的,现在使用 Function 来声明组件,已经没有了 constructor 构造函数也就没有了 props 的接收,父子组件的传值就成了一个问题,React Hooks 准备了 useContext ,它可以帮助我们跨域组件层级直 阅读全文
posted @ 2021-02-02 00:05
shanlu
阅读(290)
评论(0)
推荐(0)
摘要:
JavaScript 中拿到Reducer: 不仅仅存在 Redux 中,可以使用 JavaScript 来完成Reducer 操作。reducer 其实就是一个函数,这个函数接收两个参数,一个是状态,一个用来控制业务逻辑的判断参数(state和 action ) useReducer ,它也是Re 阅读全文
posted @ 2021-02-02 00:03
shanlu
阅读(200)
评论(0)
推荐(0)
摘要:
useContext:可以访问全局状态,避免一层层的传递状态,这符合 Redux 的一项规则,就是状态全局化,并能统一管理。 useReducer:通过 action 的传递,更新复杂逻辑的状态,主要是可以实现类似 Redux 中的 Reducer 部分,实现业务逻辑的可行性。 第一步,使用 use 阅读全文
posted @ 2021-02-02 00:02
shanlu
阅读(347)
评论(0)
推荐(0)
摘要:
useMemo 主要用来解决使用 React Hooks 产生的无用渲染的性能问题,function 的形式声明组件,失去了 shouldComponentUpdate(在组件更新之前)这个生命周期,也就是说我们没有办法通过组件更新前条件来决定组件是否更新。而且,在函数组件中,也不再区分 mount 阅读全文
posted @ 2021-02-02 00:01
shanlu
阅读(742)
评论(0)
推荐(0)

浙公网安备 33010602011771号