上一页 1 2 3 4 5 6 ··· 44 下一页
摘要: 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 阅读(66) 评论(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 阅读(434) 评论(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 阅读(47) 评论(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 阅读(415) 评论(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 阅读(56) 评论(0) 推荐(0) 编辑
摘要: useState 是 react 自带的一个 hook 函数,它的作用是用来声明状态变量 ①声明: const [ count , setCount ] = useState(0); 这种方法是 ES6 语法中的数组解构。useState 这个函数接收的参数是状态的初始值,它返回一个数组,这个数组的 阅读全文
posted @ 2021-02-02 00:08 shanlu 阅读(77) 评论(0) 推荐(0) 编辑
摘要: 在用 Class 制作组件时,经常会用生命周期函数,来处理一些额外的事情(副作用:和函数业务主逻辑关联不大,特定时间或事件中执行的动作,比如Ajax 请求后端数据,添加登录监听和取消登录,手动修改DOM等等 ),在 React Hooks 中也需要这样类似的生命周期函数,比如在每次状态更新时执行,这 阅读全文
posted @ 2021-02-02 00:07 shanlu 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 在用类声明 组件时,父子组件的传值是通过组件属性 props 进行的,现在使用 Function 来声明组件,已经没有了 constructor 构造函数也就没有了 props 的接收,父子组件的传值就成了一个问题,React Hooks 准备了 useContext ,它可以帮助我们跨域组件层级直 阅读全文
posted @ 2021-02-02 00:05 shanlu 阅读(241) 评论(0) 推荐(0) 编辑
摘要: JavaScript 中拿到Reducer: 不仅仅存在 Redux 中,可以使用 JavaScript 来完成Reducer 操作。reducer 其实就是一个函数,这个函数接收两个参数,一个是状态,一个用来控制业务逻辑的判断参数(state和 action ) useReducer ,它也是Re 阅读全文
posted @ 2021-02-02 00:03 shanlu 阅读(162) 评论(0) 推荐(0) 编辑
摘要: useContext:可以访问全局状态,避免一层层的传递状态,这符合 Redux 的一项规则,就是状态全局化,并能统一管理。 useReducer:通过 action 的传递,更新复杂逻辑的状态,主要是可以实现类似 Redux 中的 Reducer 部分,实现业务逻辑的可行性。 第一步,使用 use 阅读全文
posted @ 2021-02-02 00:02 shanlu 阅读(294) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 44 下一页