随笔分类 -  javascript

摘要:const isAddKeyFrameDom = (eTarget: HTMLElement) => { return eTarget.matches('.bf-route-add, .bf-route-add *'); }; 阅读全文
posted @ 2025-04-09 14:06 最好的年纪 阅读(23) 评论(0) 推荐(0)
摘要:临时方案:使用正则批量为所有超长字段的value添加双引号案例:将字符串里所有的id字段的值,加上双引号,之后正常使用JSON.parse方法 let _result: any = await fileUrlToData(_projectFieldConfigValue); // 使用正则表达式找到 阅读全文
posted @ 2024-08-12 11:03 最好的年纪 阅读(444) 评论(0) 推荐(0)
摘要:export const ContractBroadcastChannel = class { channelName: string; channel: BroadcastChannel; constructor() { this.channelName = 'ContractChannel'; 阅读全文
posted @ 2024-02-02 11:20 最好的年纪 阅读(52) 评论(0) 推荐(0)
摘要:function customToFixed(num: string, len: number = 2) { num = num.toString() let index = num.indexOf('.') if (index !== -1) { num = num.substring(0, in 阅读全文
posted @ 2022-04-13 18:59 最好的年纪 阅读(453) 评论(0) 推荐(0)
摘要:123456789.toLocaleString('en-US') 阅读全文
posted @ 2022-03-30 18:28 最好的年纪 阅读(70) 评论(0) 推荐(0)
摘要:const waitImgLoaded = async (root) => { const imgNodes = root instanceof HTMLImageElement ? [root] : root.querySelectorAll('img'); let imgArr = Array. 阅读全文
posted @ 2021-12-27 10:44 最好的年纪 阅读(886) 评论(0) 推荐(0)
摘要:// 正则提取字符串中的小数 str.replace(/[^\d.]/g, "") // 正则表达式 开头:^ 结尾:$ var str='&12abd3_3iw;'; var regex=/^&.*;$/; var result=regex.test(str); // 正则表达式,以字母开头,由- 阅读全文
posted @ 2021-11-08 17:36 最好的年纪 阅读(70) 评论(0) 推荐(0)
摘要:// 保留2位小数 /^([\-?[0-9]{0,4}|[0-9])+\.?[0-9]{0,2}$/.test(-0.01)true // 保留2位小数/^([\-?[0-9]{0,4}|[0-9])+\.?[0-9]{0,2}$/.test("-0.001")false 阅读全文
posted @ 2021-08-18 09:40 最好的年纪 阅读(1145) 评论(0) 推荐(0)
摘要:let _startTime = new Date(new Date().getTime() - 3600 * 1000 * 24 * 7); let _endTime = new Date(); let startTime = `${_startTime.getFullYear()} ${_sta 阅读全文
posted @ 2021-07-23 15:31 最好的年纪 阅读(367) 评论(0) 推荐(0)
摘要:var currTimestamp = new Date.getTime(); var targetTimestamp = currTimestamp + 8 * 3600 * 1000; var targetDateTime = new Date(targetTimestamp); 阅读全文
posted @ 2021-06-21 14:17 最好的年纪 阅读(1291) 评论(0) 推荐(0)
摘要:// 单击 el.onclick = function (ev) { // 取消上次延时未执行的方法 clearTimeout(el.timeFn); //执行延时 el.timeFn = setTimeout(function () { // do something 单击事件... }, 300 阅读全文
posted @ 2020-12-25 14:20 最好的年纪 阅读(375) 评论(0) 推荐(0)
摘要:原文地址:https://www.cnblogs.com/cangqinglang/p/9746650.html 1.创建事件 var myEvent = new CustomEvent('event_name', { detail:{ // 将需要传递的数据写在detail中,以便在EventLi 阅读全文
posted @ 2020-12-14 16:10 最好的年纪 阅读(595) 评论(0) 推荐(0)
摘要:accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" 阅读全文
posted @ 2020-11-05 14:26 最好的年纪 阅读(3114) 评论(0) 推荐(2)
摘要:// 这里是获取到的图片base64编码,这里只是个例子哈,要自行编码图片替换这里才能测试看到效果 const imgUrl = vp_img_base64; // 如果浏览器支持msSaveOrOpenBlob方法(也就是使用IE浏览器的时候),那么调用该方法去下载图片 if (window.na 阅读全文
posted @ 2020-09-30 16:33 最好的年纪 阅读(6772) 评论(0) 推荐(2)
摘要:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <title>二维码 阅读全文
posted @ 2020-08-20 13:12 最好的年纪
摘要:最终效果: 实现方法: // 使用js中Array类型的原生方法sort与String类型的原生方法localeCompare实现 afterSortDataList = beforeSortDataList.sort(function (a, b) { return a.name.localeCo 阅读全文
posted @ 2020-05-15 10:16 最好的年纪 阅读(973) 评论(0) 推荐(0)
摘要:/* //简写形式,效果相同 $.getJSON("http://app.example.com/base/json.do?sid=1494&busiId=101&jsonpCallback=?", function(data){ $("#showcontent").text("Result:"+d 阅读全文
posted @ 2019-11-26 17:59 最好的年纪 阅读(785) 评论(0) 推荐(0)
摘要:以生成8位字符串为例 阅读全文
posted @ 2019-09-11 10:13 最好的年纪 阅读(1122) 评论(0) 推荐(0)
摘要:今天在项目开发中遇到了image转canvas不显示的问题,最后翻了不少资料才发现问题出现在图片加载上 如果你的代码是这样的,那么不显示的原因就是img没有加载完成 这样做试试 阅读全文
posted @ 2019-09-05 15:12 最好的年纪 阅读(636) 评论(0) 推荐(0)
摘要:1.在worker.js源码文件中 写下debugger关键词 2. F12打开控制台,重新刷新页面,加载worker.js文件(注意之前的缓存,chrome推荐使用 ctrl + F5 刷新) 3. 此时可以重新给debugger关键词所在行打上断点,刷新页面即可 4.调试结束后,不要忘记删除源码 阅读全文
posted @ 2019-09-04 14:59 最好的年纪 阅读(2256) 评论(0) 推荐(0)