- 博客(27)
- 收藏
- 关注
原创 多个if-else的优化
1.多元判断时:将condition写作正则存到Map里const actions = ()=>{ const functionA = ()=>{/*do sth*/} const functionB = ()=>{/*do sth*/} const functionC = ()=>{/*send log*/} return new Map([ [/^guest_[1-4]$/,functionA], [/^guest_5$/,functionB],
2023-05-25 14:43:16
82
原创 样式auto-fit/auto-fill区别
结果:auto-fill:按照minmax给的宽度均匀划分子元素宽度,剩余的部分空白显示。auto-fit:将父盒子宽带平均分配给的现有子元素。
2023-05-25 14:40:56
322
原创 关闭端口号方法:
场景:node 报错 throw er;// Unhandled ‘error’ event 解决办法。1.进入cmd命令窗口,写netstat -ano|findstr “8080”
2023-05-25 14:35:37
78
原创 pinia简单使用
import {import {import {// 你可以对 `defineStore()` 的返回值进行任意命名,但最好使用 store 的名字,同时以 `use` 开头且以 `Store` 结尾。(比如 `useUserStore`,`useCartStore`) //store-name.ts //export enum Names { // TEST = "test", // USER = "user" // } // 第一个参数是你的应用中 Store 的唯一 ID。
2023-05-25 14:15:59
339
原创 npm安装软件遇到verb lock
当npm安装软件遇到:/ extract:vue-qriously: verb lock using C:\Users\Jun\AppData\Roaming\npm-cache_locks\staging-97d0类似的 verb lock解决办法:修改 npm 的安装目录下的 npmrc文件 增加一条 registry=http://registry.cnpmjs.org$ npm config set registry http://registry.cnpmjs.org...
2022-01-18 10:14:17
6236
原创 moment.js的运用
前30天的数组const lastThirtyDays = [...new Array(30)].map((i, idx) => moment().startOf('day').subtract(idx, 'days') );后5天包含今天 const lastFiveDays = [...new Array(5)].map((i, idx) => moment().startOf('day').subtract(-idx, 'days').format('YYYY-M
2021-06-23 18:10:47
62
原创 数组循环增加异步请求字段
async componentDidMount() { function test(i) { return new Promise((resolve, reject) => { let sino = parseInt(i * 6 + 1); setTimeout(() => { resolve(sino); }, 3000); }); } const matchInfo = [{ a: 1 }, { a: 2 }, { a: 3 }].
2021-06-16 11:39:02
132
原创 数组对象中修改某个节点的值
var tree = [ { name: 'node1' }, { name: 'node2', children: [{ name: 'node-2-1' }, { name: 'node2-2' }] }, { name: 'node3', children: [ { name: 'node-3-1', children: [{ name: 'node3-1-1' }] }, { name: 'node3-2' }, ], }, ]
2021-03-17 09:43:30
817
原创 多个if-else 的优化
1: 多元判断时:将condition写作正则存到Map里const actions = ()=>{ const functionA = ()=>{/*do sth*/} const functionB = ()=>{/*do sth*/} const functionC = ()=>{/*send log*/} return new Map([ [/^guest_[1-4]$/,functionA], [/^guest_5$/,functionB]
2020-07-17 08:59:28
655
原创 echart-堆叠的柱形图
1:正常的堆叠var option = { tooltip: { trigger: "axis", }, legend: { itemWidth: 10, // 设置宽度 itemHeight: 10, // 设置高度 data:['缺勤','出勤'], x: '4%', y: '5', textStyle: { // 图例的公
2020-07-08 16:45:06
834
原创 当天0点时间戳获取
var start = new Date(new Date(new Date().toLocaleDateString()).getTime()); // 当天0点 var end = new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1); // 当天23:59
2020-06-30 12:06:20
114
原创 元素定位区别
1.offsetLeft/offsetTop在页面任一元素的offsetLeft总是找到离其最近的已经定位的父元素或祖先元素定位,如果没有,就根据根节点body定位,然后获取其left值。元素的边框的外边缘距离与已定位的父容器(offsetparent)的左边距离(不包括元素的边框和父容器的边框)2.offset().left/offset().top返回或设置匹配元素相对于文档的偏移(位置)。 无论元素的父元素或祖先元素的position属性是什么,总是计算相对于文档的位置也就是相对于当前文档的
2020-06-28 09:44:01
243
原创 cnpm 安装
1、配置npm config set prefix “d:\nodejs\node_global”npm config set cache “d:\nodejs\node_cache”2、cnpm 安装1:npm install -g cnpm --registry=https://registry.npm.taobao.org2:配置环境变量系统环境变量配置如下:新建系统环境变量node-path如下配置用户path3、cnpm 执行失败cnpm : 无法加载文件 E:\Prog
2020-05-22 12:02:31
775
原创 遍历json树结构对象
let 0 ={ "1": { "1": { "1": ["all"] } }, "2": { "all": { "all": ["all"] } }}this.traverse(o)调用:traverse(o) { for (let i in o) { if (!!o[i] && typeof o[i...
2020-04-26 21:28:24
387
原创 axios 封装
调用:let a = get(URL1, {api: 'getPlatformSetup', user: this.USER,}) a.then(arr=>{ console.log(arr); },error=>{ console.log(error); }) let b = post(URL2, {api: 'addRoomInfo', sid: 1,...
2019-11-25 17:38:58
118
原创 es6 promise 使用
es6 promise 使用1:promise 异步多个请求判断结果获取let p1= this.verificationPicFile(URL2,'mediaServer');let p2= this.createPromise**(URL2,'mediaServer');let p3= this.createPromise**(URL2,'mediaServer1');Promise...
2019-11-25 15:03:54
197
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人