随笔分类 -  JavaScript

javascript
摘要:const onlyNumber = (num) => { var n = String(num); var t = n.charAt(0); // 先把非数字的都替换掉,除了数字和. n = n.replace(/[^\d\.]/g, ''); // 必须保证第一个为数字而不是. n = n.re 阅读全文
posted @ 2024-01-31 10:11 haha-uu 阅读(55) 评论(0) 推荐(0) 编辑
摘要:下载单张图片 import JSZip from "jszip"; import FileSaver from "file-saver"; downloadIamge(imgsrc, name) { //下载图片地址和图片名 let image = new Image(); // 解决跨域 Canv 阅读全文
posted @ 2023-01-31 14:56 haha-uu 阅读(1974) 评论(0) 推荐(0) 编辑
摘要:unique(arr,i){ for(let i=0;i<arr.length;i++){ for(let j=i+1;j<arr.length;j++){ if(arr[i].id == arr[j].id){ arr.splice(j,1) j-- } } } }, 阅读全文
posted @ 2022-07-26 11:48 haha-uu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:// obj 数组 或者 对象 // arr 要获取对象数组的对象的key数组 // addProperty 可以往对象数组的每一个对象添加一个新的属性 reducedFilter(obj, arr, addProperty) { if (typeof (obj) !== "object" || ! 阅读全文
posted @ 2022-06-25 18:02 haha-uu 阅读(2393) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/sllailcp/article/details/91397332 阅读全文
posted @ 2022-01-25 14:38 haha-uu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:获取对象数组里某些特定的属性值,在组合成新的对象数组,并返回 getObjKeysAndValue(object, str) { const voltData = []; for (let i in object) { if (i.indexOf(str) != -1) { const obj = 阅读全文
posted @ 2021-03-05 11:00 haha-uu 阅读(446) 评论(0) 推荐(0) 编辑
摘要:参考:https://blog.csdn.net/giser_whu/article/details/51485635 CompanyIndex({ _with: 'location' }) .then((res) => { if (res.data && res.success) { // thi 阅读全文
posted @ 2020-10-10 15:11 haha-uu 阅读(200) 评论(0) 推荐(0) 编辑
摘要:参考:https://juejin.im/post/6875152247714480136#heading-35 阅读全文
posted @ 2020-09-24 14:45 haha-uu 阅读(250) 评论(0) 推荐(0) 编辑
摘要:有时候我们需要在页面上添加一个类似时钟的东西来实时显示当前时间,这个时候我们可以利用定时器来完成这个功能 <div id="app"> {{date}} </div> <script> export default { data() { return { date: new Date() }; }, 阅读全文
posted @ 2020-09-13 21:26 haha-uu 阅读(2083) 评论(0) 推荐(0) 编辑
摘要:参考:https://www.cnblogs.com/catgatp/p/13178934.html 用JS将指定时间转化成用户当地时区的时间: 参考:https://www.cnblogs.com/simendancer/p/5165023.html 容易理解: https://blog.csdn 阅读全文
posted @ 2020-09-13 10:53 haha-uu 阅读(1711) 评论(0) 推荐(0) 编辑
摘要:^(([1-9]\d*)(\.\d{1,2})?)$|(0\.0?([1-9]\d?))$ 验证参考: 可以为0的金额验证正则表达式如下: ^(([1-9]\d*)|0)(\.\d{1,2})?$ 参考:http://www.tashan10.com/huo-bi-jin-e-javascriptz 阅读全文
posted @ 2020-09-05 22:42 haha-uu 阅读(1888) 评论(0) 推荐(0) 编辑
摘要:时间格式化参考:https://www.cnblogs.com/zhoushuang0426/p/10559172.html js获取当前时间戳;指定时间转换时间戳;时间戳转换时间:参考https://blog.csdn.net/qq_37896578/article/details/9008095 阅读全文
posted @ 2020-08-05 14:11 haha-uu 阅读(4751) 评论(0) 推荐(0) 编辑
摘要:1、使用hover 2、使用方法 <div class="item" @mouseover="showqrcode()" @mouseout="hideqrcode()"> <icon-svg icon-class="iconwechat" /> </div> showqrcode() { this 阅读全文
posted @ 2020-07-25 16:29 haha-uu 阅读(1030) 评论(0) 推荐(0) 编辑
摘要:参考: https://www.cnblogs.com/pengcc/p/4126687.html 图解参考: https://blog.csdn.net/mxclsh/article/details/84853854 阅读全文
posted @ 2020-07-07 16:04 haha-uu 阅读(184) 评论(0) 推荐(0) 编辑
摘要:var a = new Boolean(""); // false var b = new Boolean("a"); // true var c = new Boolean(0); // false var c2 = new Boolean(1); // true var d = new Bool 阅读全文
posted @ 2020-06-23 14:42 haha-uu 阅读(162) 评论(0) 推荐(0) 编辑
摘要:在common.js中: // 全屏 export function requestFullScreen(element) { const docElm = element; if (docElm.requestFullscreen) { docElm.requestFullscreen(); } 阅读全文
posted @ 2020-06-22 17:33 haha-uu 阅读(483) 评论(0) 推荐(0) 编辑
摘要:不足2位补'0': 也有个函数padStart(),padEnd() https://blog.csdn.net/ixygj197875/article/details/79090578 export function pad(num, n = 2) { let len = num.toString 阅读全文
posted @ 2020-06-16 18:44 haha-uu 阅读(184) 评论(0) 推荐(0) 编辑
摘要:https://www.cnblogs.com/HSHS/p/7943161.html 阅读全文
posted @ 2020-06-09 16:40 haha-uu 阅读(399) 评论(0) 推荐(0) 编辑
摘要:放代码: 给要拖拽的盒子设置:决定定位 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initia 阅读全文
posted @ 2020-05-15 18:10 haha-uu 阅读(181) 评论(0) 推荐(0) 编辑

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