会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
九月九九八
博客园
首页
新随笔
联系
订阅
管理
2022年1月4日
前端开发 js es 关于输入框非空的判断
摘要: if(value !== null && value !== undefined && value !== ''){ //... } 上面的是平时的写法,看到个更优雅的写法; if((value??'') !== ''){ //... }
阅读全文
posted @ 2022-01-04 17:57 九月九九八
阅读(130)
评论(0)
推荐(0)
2021年12月28日
前端web开发--如何严格判断文件上传类型?而不是单纯靠文件的后缀名
摘要: PS:此文章来源于https://juejin.cn/post/7046002905278578725 文件上传是工作中常见的业务需求,很多情况下,我们需要限制文件的上传类型,比如只能上传图片。通常我们是通过input元素的accept属性来限制文件的类型: <input id="file" typ
阅读全文
posted @ 2021-12-28 14:33 九月九九八
阅读(1726)
评论(0)
推荐(0)
2021年12月24日
reduce求和,最小值和最大值
摘要: 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)
2021年12月6日
Phone-reset样式初始化
摘要: /* 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)
pc-reset PC样式初始化
摘要: /* 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)
js 其它操作
摘要: /*获取网址参数*/ 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)
js Storage 储存操作
摘要: 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)
js http
摘要: /** * @param {setting} */ ajax(setting){ //设置参数的初始值 var opts={ method: (setting.method || "GET").toUpperCase(), //请求方式 url: setting.url || "", // 请求地址
阅读全文
posted @ 2021-12-06 10:41 九月九九八
阅读(106)
评论(0)
推荐(0)
js Number
摘要: /*随机数范围*/ 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)
js String 字符串操作
摘要: /** * 去除空格 * @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)
下一页
公告