摘要: if(value !== null && value !== undefined && value !== ''){ //... } 上面的是平时的写法,看到个更优雅的写法; if((value??'') !== ''){ //... } 阅读全文
posted @ 2022-01-04 17:57 九月九九八 阅读(130) 评论(0) 推荐(0)
摘要: PS:此文章来源于https://juejin.cn/post/7046002905278578725 文件上传是工作中常见的业务需求,很多情况下,我们需要限制文件的上传类型,比如只能上传图片。通常我们是通过input元素的accept属性来限制文件的类型: <input id="file" typ 阅读全文
posted @ 2021-12-28 14:33 九月九九八 阅读(1726) 评论(0) 推荐(0)
摘要: const array = [5,4,7,8,9,2]; 求和 array.reduce((a,b) => a+b); // 输出: 35 最大值 array.reduce((a,b) => a>b?a:b); // 输出: 9 最小值 array.reduce((a,b) => a<b?a:b); 阅读全文
posted @ 2021-12-24 10:40 九月九九八 阅读(95) 评论(0) 推荐(0)
摘要: /* normalize.css */ html { line-height: 1.15; /* 1 */ -ms-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%; /* 2 */ } body { margin: 0; 阅读全文
posted @ 2021-12-06 10:45 九月九九八 阅读(42) 评论(0) 推荐(0)
摘要: /* normalize.css */ html { line-height: 1.15; /* 1 */ -ms-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%; /* 2 */ } body { margin: 0; 阅读全文
posted @ 2021-12-06 10:44 九月九九八 阅读(59) 评论(0) 推荐(0)
摘要: /*获取网址参数*/ getURL(name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if(r!=null) return 阅读全文
posted @ 2021-12-06 10:43 九月九九八 阅读(32) 评论(0) 推荐(0)
摘要: class StorageFn { constructor () { this.ls = window.localStorage; this.ss = window.sessionStorage; } /* cookie */ /*设置cookie*/ setCookie (name, value, 阅读全文
posted @ 2021-12-06 10:42 九月九九八 阅读(395) 评论(0) 推荐(0)
摘要: /** * @param {setting} */ ajax(setting){ //设置参数的初始值 var opts={ method: (setting.method || "GET").toUpperCase(), //请求方式 url: setting.url || "", // 请求地址 阅读全文
posted @ 2021-12-06 10:41 九月九九八 阅读(106) 评论(0) 推荐(0)
摘要: /*随机数范围*/ random (min, max) { if (arguments.length 2) { return Math.floor(min + Math.random() * ( (max+1) - min )) }else{ return null; } } /*将阿拉伯数字翻译成 阅读全文
posted @ 2021-12-06 10:41 九月九九八 阅读(65) 评论(0) 推荐(0)
摘要: /** * 去除空格 * @param {str} * @param {type} * type: 1-所有空格 2-前后空格 3-前空格 4-后空格 * @return {String} */ trim (str, type) { type = type || 1 switch (type) { 阅读全文
posted @ 2021-12-06 10:40 九月九九八 阅读(37) 评论(0) 推荐(0)