摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script> window.onload=function(){ var oBtn=document.getElementById('btn'); var o
阅读全文
随笔分类 - function
一些常用的函数
摘要:有一个pad端需求,要求进到项目之后在浏览器中将整个项目全屏, window.onload = () => { let element = document.documentElement if (element.requestFullscreen) { element.requestFullscr
阅读全文
摘要:(function() { var ROOT = this; var DECIMAL_SEPARATOR = '.'; // Decimal var Decimal = function(num) { if(this.constructor != Decimal) { return new Deci
阅读全文
摘要:不精准原因: 下面我们来说一下浮点数运算产生误差的原因:(拿0.1+0.2=0.30000000000000004进行举例) 首先,我们要站在计算机的角度思考 0.1 + 0.2 这个看似小儿科的问题。我们知道,能被计算机读懂的是二进制,而不是十进制,所以我们先把 0.1 和 0.2 转换成二进制看
阅读全文
摘要:浏览器的PWA模式是一种可安装(Installable), 可以出现在设备的主屏幕。 关于开发如何识别PWA模式 const isInStandaloneMode = () => (window.matchMedia('(display-mode: standalone)').matches) ||
阅读全文
摘要:toFixed()方法采用1 个参数,即精确的小数位数。 let num = 12.345678; // default toFixed() method console.log(num.toFixed()); // 12 逗号分隔的内置方法 这些格式可以通过使用toLocaleString()方法
阅读全文
摘要:(function(){ let datas = [1,2,3,4,5,1,5,'e', 'm', '3'] datas = datas.filter((item, index, arr) => { console.log(item, index, arr); console.log(arr.ind
阅读全文
摘要:<template> <div class="drag-ball" ref="dragBall" @mousedown.stop.prevent="mousedown" @mouseup.stop.prevent="mouseup"> <div class="drag-content"> <slot
阅读全文
摘要:连续操作:两个操作之间的时间间隔小于设定的阀值,这样子的一连串操作视为连续操作。 debounce(防抖):一个连续操作中的处理,只触发一次,从而实现防抖动。throttle:一个连续操作中的处理,按照阀值时间间隔进行触发,从而实现节流。 发生的情况: a、scroll事件:当页面发生滚动时,scr
阅读全文
摘要:function isString(obj) { return Object.prototype.toString.call(obj) '[object String]'; } function isObject(obj) { return Object.prototype.toString.cal
阅读全文
摘要:function(a,b){ return a.localeCompare(b, undefined, {sensitivity: 'base'}) }
阅读全文
摘要:下面部分来自:https://www.cnblogs.com/chenmeng0818/p/6370819.html js中的正则表达式入门 什么是正则表达式呢? 正则表达式(regular expression)描述了一种字符串匹配的模式,可以用来检查一个字符串是否含有某种子串、将匹配的子串做替换
阅读全文
摘要:rules: { name: [ { required: true, validator: (rule, value, callback) => { if (!value) { return callback(new Error("请输入名称")); }else{ //这个else 一定要写, 要不
阅读全文
摘要://复制文本信息 copyContext(val){ const input = document.createElement('input') document.body.appendChild(input) input.setAttribute('value',val) input.select
阅读全文
摘要:请求加入responseType = "blob"; —————————————————————————————————————— api.then(res =>{ //用来读取文件blob返回type为application/json的错误信息 if (res.response.type 'app
阅读全文
摘要:dllalsdf(){ // 获取时间戳 let timestamp=new Date().getTime(); // 获取XMLHttpRequest let xmlResquest = new XMLHttpRequest(); // 发起请求 xmlResquest.open("POST",'
阅读全文
摘要:function isEmpty(v) { switch (typeof v) { case 'undefined': return true; case 'string': if (v.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0)
阅读全文