随笔分类 - javascript
一些javascript中常用的方法
摘要:安装: npm install sm-cryptoOr yarn add sm-crypto sm2: 获取密钥对: const sm2 = require('sm-crypto').sm2 let keypair = sm2.generateKeyPairHex() publicKey = key
阅读全文
摘要:网址:https://501351981.github.io/vue-office/examples/docs/
阅读全文
摘要:在我们正常的思维看来,toFixed是四舍五入的,但是会出现例外,如: 发现5.215的toFixed并不是5.22,其实这个的原理类似于0.1+0.2≠0.3是一个原理,如: 发现5.215的底层是5.12499999999...,那么此时按照奇进偶舍的规则,第三位4小于5直接舍弃,就成了5.21
阅读全文
摘要:封装js(utils/geolocation.min.js): window.qq=window.qq||{},qq.maps=qq.maps||{},window.soso||(window.soso=qq),soso.maps||(soso.maps=qq.maps),qq.maps.Geolo
阅读全文
摘要:utils/exportexcel.js import { parseTime } from '@/utils/format'; import { Message } from 'element-ui'; /** * 导出Excel文件 * @param {*} data 文件数据流 * @para
阅读全文
摘要:html: <div class="home-main-dictum-info"> <span>{{ dictumInfo }}</span> <span class="home-main-typed-cursor" :class="{ 'is-typed-cursor-anmation': wat
阅读全文
摘要:1、通过id选择器来替换内容打印 html: <div ref="printQRCodeRef"> <div class="qrcode-dialog-container"> <img :src="locatorQRCodeDialogObj.qrcodeImgUrl" /> <div ref="l
阅读全文
摘要:直接上代码: const res = []; function test1() { for(let i = 0; i<50000000; i++) { res.push(i) } if (res.length < 50000000) { // 是否已完成 setTimeout(test1, 0);
阅读全文
摘要:我们可以选择使用try...catch的方式进行跳出循环。 const arr = [0, 1, 2, 3, 4, 5]; try { arr.forEach((item) => { console.log('正常循环:', item); if (item 2) { throw item; } })
阅读全文
摘要:function doCombination(arr) { const count = arr.length - 1; //数组长度(从0开始) let [tmp, totalArr] = [[], []]; return doCombinationCallback(arr, 0); // 从第一个
阅读全文
摘要:ES7: Array.prototype.includes(n)// 判断Array是否包含了n,返回布尔值。 2**10; // 1024 ES8: Object.values()// 拿取对象的value Object.values({a: 1, b: 2, c: 3}); // [1, 2,
阅读全文
摘要:HTML: <div class="clock"> <div class="outer-clock-face"> <div class="marking marking-one"></div> <div class="marking marking-two"></div> <div class="m
阅读全文
摘要:const list = [ { type: 'shop', momey: 223 }, { type: 'study', momey: 341 }, { type: 'shop', momey: 821 }, { type: 'transfer', momey: 821 }, { type: 's
阅读全文
摘要:需求:多维数组=>一维数组 let ary = [1, [2, [3, [4, 5]]], 6];// -> [1, 2, 3, 4, 5, 6] let str = JSON.stringify(ary); 1. 调用ES6中的flat方法 ary = ary.flat(Infinity); 2.
阅读全文
摘要:方法1:array.indexOf 此方法判断数组中是否存在某个值,如果存在,则返回数组元素的下标,否则返回-1。 var arr=[1,2,3,4]; var index=arr.indexOf(3); console.log(index); 方法2:array.includes(searcEle
阅读全文
摘要:String.prototype.byteLength = function() { //获取字符串的字节数 var b = 0, l = this.length; //初始化字节数递加变量并获取字符串参数的字符个数 if(l) { //如果存在字符串,则执行计划 for(var i = 0; i
阅读全文
摘要:html: <button>Button</button> css: button { min-width: 100px; max-width: 150px; min-height: 40px; border: 0; outline: 0; color: white; background: #ee
阅读全文
摘要:1、过滤唯一值: const arr = [1, 1, 2, 3, 5, 5, 1] const uniqueArr = [...new Set(arr)] console.log(uniqueArr) // [1,2,3,5] 其中的Set为es6新增属性 2、与或运算: 其实与或运算的精简之处就
阅读全文
摘要:1、箭头函数 eg: (a, b) => a * b 等价于 function (a, b) { return a * b } 具体箭头函数讲解, 请看:http://www.javascriptkit.com/javatutors/javascriptarrowfunctions.shtml 2、
阅读全文

浙公网安备 33010602011771号