随笔分类 -  js

摘要:// if (datas.key 'telephoneNumber') {// const { val } = datas// const patrn1 = /^(1[3-9]\d{9}$)/// const patrn = /^(([0-9]{3,4}[-])?[0-9]{7,8}$)/// le 阅读全文
posted @ 2022-07-27 10:52 谎渊 阅读(390) 评论(0) 推荐(0)
摘要:// mathjs 四舍五入取整 val:值export function roundingInt(val) { if (val) { return math.round(val, 0) }}// mathjs 四舍五入 val:值,num:小数位export function rounding(v 阅读全文
posted @ 2022-07-27 10:49 谎渊 阅读(190) 评论(0) 推荐(0)
摘要:/* * 参数说明:* number:要格式化的数字* decimals:保留几位小数 * dec_point:小数点符号* thousands_sep:千分位符号* */export function numberDivision(number, decimals, dec_point, thou 阅读全文
posted @ 2022-07-27 10:42 谎渊 阅读(168) 评论(0) 推荐(0)
摘要:// 搜索过滤 val:传入值, list:列表数组, key:对比字段, filterIndex:过滤开始的索引export function dataFilter(val, list, key, filterIndex) { filterIndex = filterIndex >= 0 ? fi 阅读全文
posted @ 2022-07-27 10:39 谎渊 阅读(58) 评论(0) 推荐(0)
摘要:arrFilter(val1, val2, key1, key2) { const val = [] // 保存遍历时要留下的项 const res = [] for (let len = 0; len < val1.length; len++) { const item = val1[len] l 阅读全文
posted @ 2022-05-27 09:43 谎渊 阅读(256) 评论(0) 推荐(0)
摘要:formateSeconds(endTime){ let secondTime = parseInt(endTime)//将传入的秒的值转化为Number let min = 0// 初始化分 let h =0// 初始化小时 let result='' if(secondTime>=60){//如 阅读全文
posted @ 2022-03-20 18:25 谎渊 阅读(1207) 评论(0) 推荐(0)
摘要:vue资源库中有个插件很好用vue-cookies 安装 npm install vue-cookies --save import VueCookies from 'vue-cookies' Vue.use(VueCookies) $cookies.config() 设置默认值 this.$coo 阅读全文
posted @ 2022-03-07 14:06 谎渊 阅读(70) 评论(0) 推荐(0)
摘要:对象同理 1. let a=[1,2,3] let b=[0,...a] //[0,1,2,3] 2. let a=[1,2,3] let [b,..c]=a //[1,2,3] //b=1,c=2,3 阅读全文
posted @ 2021-11-24 14:38 谎渊 阅读(44) 评论(0) 推荐(0)
摘要:document.body.clientWidth ==> BODY对象宽度 2 document.body.clientHeight ==> BODY对象高度 3 document.documentElement.clientWidth ==> 可见区域宽度 4 document.document 阅读全文
posted @ 2021-11-11 15:05 谎渊 阅读(110) 评论(0) 推荐(0)
摘要:使用addEventListener('事件类型',函数,false?true冒泡?捕获)方法 <ul> <li>1</li> <li>2</li> </ul> var uls=document.querySelector('ul') uls.addEventListener('click',fun 阅读全文
posted @ 2021-10-05 14:07 谎渊 阅读(30) 评论(0) 推荐(0)
摘要:构造函数 function Myfun(){ this.height=170 this.weight=100 } 原型对象 Myfun.prototype.name="小林" 实例 var Myfuns=new Myfun() console.log(Myfuns.height)//170 cons 阅读全文
posted @ 2021-09-28 23:57 谎渊 阅读(21) 评论(0) 推荐(0)
摘要:可用箭头函数 (v,i)=>{ } 或 (v,i)=>v==条件? v:false //不能使用return 判断是否存在这个元素 arr.includes(元素值) 返回值 true false 判断符合条件的元素 arr.find(v=>v==条件) 返回 该元素 (只返回一个值) arr.fi 阅读全文
posted @ 2021-09-28 23:48 谎渊 阅读(35) 评论(0) 推荐(0)
摘要:vue || js promise fun(){ var this=that new promise((resolve,reject)=>{ that.get().then(res=>{ resolve(res) }) }).then(res=>{ console.log(res) }) } 或 f 阅读全文
posted @ 2021-09-28 23:24 谎渊 阅读(30) 评论(0) 推荐(0)
摘要:在对象.sort()里使用一个函数,这个函数要给一个排序标准的元素名称 let key='元素名称' let arrSort=(key)=>{ return (after,before)=>{ let afters=after[key] let befores=before[key] if(afte 阅读全文
posted @ 2021-09-28 23:13 谎渊 阅读(34) 评论(0) 推荐(0)