上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 43 下一页
摘要: 1. 需要⼀个store来存储数据 2. store⾥的reducer初始化state并定义state修改规则 3. 通过dispatch⼀个action来提交对数据的修改 4. action提交到reducer函数⾥,根据传⼊的action的type,返回新的 state 创建store,src/ 阅读全文
posted @ 2020-06-30 18:34 又回到了起点 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 什么是reduce const array1 = [1, 2, 3, 4]; const reducer = (accumulator, currentValue) => accumulator + currentValue; // 1 + 2 + 3 + 4 console.log(array1. 阅读全文
posted @ 2020-06-29 15:48 又回到了起点 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 什么是reducer reducer 就是⼀个纯函数,接收旧的 state 和 action,返回新的 state。 (previousState, action) => newState 之所以将这样的函数称之为 reducer,是因为这种函数与被传⼊ Array.prototype.reduce 阅读全文
posted @ 2020-06-28 18:56 又回到了起点 阅读(140) 评论(0) 推荐(0) 编辑
摘要: getUrlParameter (param, dummyPath) { let sPageURL = window.location.hash || window.location.search.substring(1) // console.log(sPageURL) let sURLVaria 阅读全文
posted @ 2020-06-24 16:16 又回到了起点 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 在部署上线后经常出现js、css缓存问题 导致样式等 区分不同的缓存 hash hash是跟整个webpack构建项目相关的,每次项目构建hash对应的值都是不同的,即使项目文件没有做“任何修改”。 其实是有修改的,因为每次webpack打包编译都会注入webpack的运行时代码,导致整个项目有变化 阅读全文
posted @ 2020-06-23 16:17 又回到了起点 阅读(934) 评论(0) 推荐(0) 编辑
摘要: 组件的单元测试有很多好处: 提供描述组件⾏为的⽂档 节省⼿动测试的时间 减少研发新特性时产⽣的 bug 改进设计 促进重构 单测 单元测试(unit testing),是指对软件中的最⼩可测试单元进⾏检查和验证。 在vue中,推荐⽤Mocha+chai 或者jest,咱们使⽤jest演示,语法基本⼀ 阅读全文
posted @ 2020-06-11 14:31 又回到了起点 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 概述:基于Promise的ORM(Object Relation Mapping),⽀持多种数据库、事务、关联等 (async () => { const Sequelize = require("sequelize"); // 建⽴连接 const sequelize = new Sequeliz 阅读全文
posted @ 2020-06-10 18:12 又回到了起点 阅读(275) 评论(0) 推荐(0) 编辑
摘要: node.js原⽣驱动 // mysql.js const mysql = require("mysql"); // 连接配置 const cfg = { host: "localhost", user: "root", password: "example", // 修改为你的密码 databas 阅读全文
posted @ 2020-06-08 14:03 又回到了起点 阅读(188) 评论(0) 推荐(0) 编辑
摘要: node.js中实现持久化的多种⽅法 ⽂件系统 fs 数据库 关系型数据库-mysql ⽂档型数据库-mongodb 键值对数据库-redis ⽂件系统数据库 // fsdb.js // 实现⼀个⽂件系统读写数据库 const fs = require("fs"); function get(key 阅读全文
posted @ 2020-06-05 16:40 又回到了起点 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 贪⼼算法是⼀种求近似解的思想。当能满⾜⼤部分最优解时就认为符合逻辑要求。 还⽤找零 这个案例为例, 考虑使⽤贪⼼算法解题: ⽐如当找零数为 36 时, 从硬币数的最⼤值 20 开始填充, 填充不下后再⽤ 10 来填充, 以此类推, 找到最优解。 场景: 假如有 1, 5, 10, 20,50,100 阅读全文
posted @ 2020-06-04 23:10 又回到了起点 阅读(205) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 43 下一页