数组去重

摘要: //普通数组去重// let arr = [1,2,3,5,1,4,5,2,3,2] //第一种方法// let arr2=[...new Set(arr)]// console.log(arr2)// console.log(arr2[2]) //第二种方法// function noRepeat 阅读全文
posted @ 2020-10-17 15:47 刘二鹏 阅读(83) 评论(0) 推荐(0) 编辑

数组列表中按照对象的某个字段排序

摘要: let series=[ {name:'西安市',value:100}, {name:'威阳市',value:120}, {name:'延安市',value:80}, {name:'南洛市',value:90}, {name:'榆林市',value:130} ] function sortBy(pr 阅读全文
posted @ 2020-10-16 11:07 刘二鹏 阅读(670) 评论(0) 推荐(0) 编辑

ToFixed

摘要: /*保留小数(四舍五入)data:要保留的数,val:保留的位数*/ function ToFixed(data,val){ var numbers = ''; // 保留几位小数后面添加几个0 for (var i = 0; i < val; i++) { numbers += '0'; } va 阅读全文
posted @ 2020-06-18 18:26 刘二鹏 阅读(223) 评论(0) 推荐(0) 编辑

H5 获取手机设备信息

摘要: isEquipment(){ let UA = navigator.userAgent, isAndroid = /android|adr|linux/gi.test(UA), isIOS = /iphone|ipod|ipad/gi.test(UA) && !isAndroid, isBlackB 阅读全文
posted @ 2020-06-17 13:12 刘二鹏 阅读(14544) 评论(0) 推荐(0) 编辑

随机数

摘要: Math.floor(Math.random() * n ) 0-(n-1)之间的随机数(整数) 阅读全文
posted @ 2020-03-30 16:27 刘二鹏 阅读(122) 评论(0) 推荐(0) 编辑

移动端适配和三秒点击延迟

摘要: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" /> <script src="https://as.ali 阅读全文
posted @ 2020-03-17 15:15 刘二鹏 阅读(288) 评论(0) 推荐(0) 编辑

清除浮动解决父元素高度塌陷问题

摘要: <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> #wrap{ width: 500px; /*height: 300px;*/ background: red; } 阅读全文
posted @ 2019-12-03 15:35 刘二鹏 阅读(136) 评论(0) 推荐(0) 编辑

canvas画动图

摘要: <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .canvasWrap{ width:500px; height: 500px; background: #CDCD 阅读全文
posted @ 2019-10-30 14:05 刘二鹏 阅读(899) 评论(0) 推荐(0) 编辑

vue实现列表的循环滚动

摘要: <template> <div id="box"> <div id="con1" ref="con1" :class="{anim:animate==true}" @mouseenter="mEnter" @mouseleave="mLeave"> <p v-for='item in items'> 阅读全文
posted @ 2019-10-23 09:29 刘二鹏 阅读(19870) 评论(0) 推荐(0) 编辑

localStorage读写操作

摘要: // 使用函数模块,因为需要实现本地读和写两个功能const TODO_KEY = 'todo_key'export default { readTodos () { // 如果没有todos数据则返回空数组 return JSON.parse(localStorage.getItem(TODO_K 阅读全文
posted @ 2019-09-26 15:58 刘二鹏 阅读(1124) 评论(0) 推荐(0) 编辑