随笔分类 -  处理字符串和数据结构方法集合和格式时间戳

摘要:<!-- 增加v-thousands指令 --> <el-input-number v-model="row.money" v-thousands :controls="false" :min="0" :precision="2" style="width: 100%" // 添加全局指令或局部指令 阅读全文
posted @ 2023-10-23 15:02 小白咚 阅读(2469) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2023-03-24 15:34 小白咚 阅读(15) 评论(0) 推荐(0) 编辑
摘要:使用场景:根据数(对象)组中的id或者其他属性去重,或者对象中的所有属性值相同的去重。传统方法:通过数组的some进行逐项判断;用了lodash之后发现还是很香的。 import { isEqual, uniqWith, uniqBy } from 'lodash' let arr = [ {id: 阅读全文
posted @ 2023-01-14 14:47 小白咚 阅读(1372) 评论(0) 推荐(0) 编辑
摘要:// 去掉前后空格 // if (this.model.agentLevel) { // this.model.agentLevel = this.model.agentLevel.trim() // } // sn编号 let newString = this.model.agentLevel.r 阅读全文
posted @ 2021-10-29 14:38 小白咚 阅读(178) 评论(0) 推荐(0) 编辑
摘要:function getNowFormatDate() { var date = new Date(); var seperator1 = "-"; var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate 阅读全文
posted @ 2021-06-19 10:49 小白咚 阅读(385) 评论(0) 推荐(0) 编辑
摘要:getDaysNumber(date){ let curDate = new Date(Date.parse(date.replace(/-/g,"/")));; let y = curDate.getFullYear(); let m = curDate.getMonth() + 1;//本身就得 阅读全文
posted @ 2021-03-01 13:56 小白咚 阅读(228) 评论(0) 推荐(0) 编辑
摘要:获取指定日期的前几天或后几天 date代表指定日期,格式:2018-09-27 day代表天数,-1代表前一天,1代表后一天 // date 代表指定的日期,格式:2018-09-27 // day 传-1表始前一天,传1表始后一天 // JS获取指定日期的前一天,后一天 function getN 阅读全文
posted @ 2021-02-20 15:54 小白咚 阅读(926) 评论(0) 推荐(0) 编辑
摘要:Array.unshift(Array.splice(index,1)[0]); 阅读全文
posted @ 2021-01-13 11:59 小白咚 阅读(200) 评论(0) 推荐(0) 编辑
摘要:js中数组操作方法整理 https://www.jianshu.com/p/22a4c0b514fa 常见方法,一看就会用的,就不代码去实现操作了,复杂的就demo一下。 1. join() 功能:将数组中所有元素都转化为字符串并连接在一起。 2. reverse() 功能:将数组中的元素颠倒顺序。 阅读全文
posted @ 2021-01-13 11:44 小白咚 阅读(394) 评论(1) 推荐(0) 编辑
摘要:myObj = {'firstName':'Ada','lastName':'Lovelace'}; for (var key in myObj) { if (myObj.hasOwnProperty(key)) { console.log(myObj[key]); } } 对象 for-in 循环 阅读全文
posted @ 2020-12-16 15:30 小白咚 阅读(938) 评论(0) 推荐(0) 编辑
摘要:// 转为时间戳//2014-07-10 10:21:12的时间戳为:1404958872 zhuanhuan(stringTime){ // var stringTime = "2014-07-10 10:21:12"; var timestamp2 = stringTime.replace(/- 阅读全文
posted @ 2020-11-03 17:21 小白咚 阅读(2736) 评论(0) 推荐(0) 编辑
摘要:// 去除数组的重复成员 [...new Set(array)]方法二: function dedupe(array) { return Array.from(new Set(array)); } dedupe([1, 1, 2, 3]) // [1, 2, 3] 原理 :ES6 提供了新的数据结构 阅读全文
posted @ 2020-10-19 14:01 小白咚 阅读(1168) 评论(0) 推荐(0) 编辑
摘要:String() 1 2 3 4 5 6 7 8 String(string); // 'hello' String(number); // '123' String(boolean); // 'true' String(array); // '1,2,3' String(object); // ' 阅读全文
posted @ 2020-08-21 11:57 小白咚 阅读(1856) 评论(0) 推荐(0) 编辑
摘要:字符串扩展 新的API ES6为字符串扩展了几个新的API: includes():返回布尔值,表示是否找到了参数字符串。 startsWith():返回布尔值,表示参数字符串是否在原字符串的头部。 endsWith():返回布尔值,表示参数字符串是否在原字符串的尾部。 map():接收一个函数,将 阅读全文
posted @ 2020-04-29 09:21 小白咚 阅读(178) 评论(0) 推荐(0) 编辑
摘要:var d = new Date();var datetime=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.g 阅读全文
posted @ 2020-04-16 14:20 小白咚 阅读(1737) 评论(2) 推荐(1) 编辑
摘要:var newDate=/\d{4}-\d{1,2}-\d{1,2}/g.exec(this.clickRow.weekDate) 阅读全文
posted @ 2020-04-16 14:19 小白咚 阅读(515) 评论(0) 推荐(0) 编辑
摘要:/** * 获取本周、本季度、本月、上月的开始日期、结束日期 */ var now = new Date(); //当前日期 var nowDayOfWeek = now.getDay(); //今天本周的第几天 var nowDay = now.getDate(); //当前日 var nowMo 阅读全文
posted @ 2020-04-06 09:38 小白咚 阅读(2535) 评论(0) 推荐(1) 编辑
摘要:js 判断字符串中是否包含某个字符串 #1 indexOf方法 //str.indexOf("")的值为-1时表示不包含var str = "hello Tara";if(str.indexOf("Tara") !== -1){ alert("Hi,Tara");} #2 includes方法 // 阅读全文
posted @ 2020-03-31 14:14 小白咚 阅读(17430) 评论(1) 推荐(1) 编辑
摘要:// 分钟转化成多少小时多少分钟 toHourMinute(minutes){ return (Math.floor(minutes/60) + "小时" + (minutes%60) + "分" ); // 也可以转换为json,以方便外部使用 // return {hour:Math.floor 阅读全文
posted @ 2020-03-26 09:20 小白咚 阅读(1597) 评论(0) 推荐(0) 编辑
摘要:1.将字符串格式的日期转化为时间戳 var date = new Date(this.value2)2.转化 this.dataForm.dateTime = date.getFullYear() + '-' + this.checkTime(date.getMonth() + 1) + '-' + 阅读全文
posted @ 2020-03-24 16:58 小白咚 阅读(11427) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示