上一页 1 2 3 4 5 6 7 ··· 9 下一页
摘要: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,u 阅读全文
posted @ 2021-03-01 15:26 li阿根 阅读(613) 评论(0) 推荐(0) 编辑
摘要: web开发中,我们经常遇到客户要显示第几周的等等麻烦的计算,那么输入当前日期如何快速查处是第几周呢? let date = new Date('2021-02-28') getWeekInYear(date) function getWeekInYear(date) { console.log(da 阅读全文
posted @ 2021-02-24 10:26 li阿根 阅读(2966) 评论(0) 推荐(0) 编辑
摘要: 根据树结构中某个字段的true/false关系,筛选出为true的树 let arr = [ { a: true, child: [ { a: true, b: 2 }, { a: false, b: 3 } ] }, { a: true, child: [ { a: true, b: 2, chi 阅读全文
posted @ 2021-02-24 10:09 li阿根 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 在web开发中,我们经常遇到数组对象结构,例如数组对象: const arr = [ {name: "孔八", label: '嘿嘿嘿'}, {name: "张三", label: '吼吼吼'}, {name: "赵四", label: '啵啵啵'}, {name: "王五", label: '嘀嘀 阅读全文
posted @ 2021-02-24 09:44 li阿根 阅读(1190) 评论(0) 推荐(0) 编辑
摘要: 做前端的小伙伴经常对于复杂的数据结构很头疼,尤其遇到多维数组 例如 var arr=[1,[2,3],4,[5,6,7]]我们如何将它变为数组[1,2,3,4,5,6,7]呢? var entries = [1, [2, 5], [6, 7], 9]; var flat_entries = [].c 阅读全文
posted @ 2021-02-19 15:09 li阿根 阅读(2295) 评论(0) 推荐(0) 编辑
摘要: 每一位程序员不想让自己的代码写的特别冗余,能用一行解决的事情坚决不写两行。今天给大家分享几个常见的简写方式 1、变量的声明 //Longhand let x; let y = 20; //Shorthand let x, y = 20; 2、给多个变量赋值 //Longhand let a, b, 阅读全文
posted @ 2021-02-19 14:54 li阿根 阅读(967) 评论(0) 推荐(0) 编辑
摘要: 在 JS 中,?? 运算符被称为非空运算符。如果第一个参数不是 null/undefined(译者注:这里只有两个假值,但是 JS 中假值包含:未定义 undefined、空对象 null、数值 0、空数字 NaN、布尔 false,空字符串'',不要搞混了),将返回第一个参数,否则返回第二个参数。 阅读全文
posted @ 2021-02-19 14:25 li阿根 阅读(1305) 评论(0) 推荐(0) 编辑
摘要: 很多做管理后台的前端小伙伴经常用到一些验证规则,比如手机号、邮箱、输入位数等,今天跟大家分享一下如何判断输入框中输入的是否为合法的手机号码 利用正则表达式进行判断: function checkPhone(p, required = true) { if (!p) { return required 阅读全文
posted @ 2021-02-19 14:13 li阿根 阅读(3143) 评论(0) 推荐(1) 编辑
摘要: web前端开发中,我们经常用到一些常见的方法,有时候重复写的特别多,代码冗余、所以花时间整理了一些常见的js方法,判断是否为undefined、是否为NaN、js合并数组、js筛选数组对象、js替换数组对象中的key、js日期格式化等,备用! //判断是否为undefined function is 阅读全文
posted @ 2021-01-04 16:59 li阿根 阅读(428) 评论(0) 推荐(0) 编辑
摘要: get请求 let url = ""; this.$axios({ url: url, method: "get", params: { a: 1, b: 2 }, }).then((res) => { console.log(res); }).catch(function(error) { // 阅读全文
posted @ 2020-11-03 10:36 li阿根 阅读(229) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 9 下一页