随笔分类 - javascript
摘要:在编程中,事件入栈(Event Pushing)和出栈(Event Popping)通常与事件循环(Event Loop)和消息队列(Message Queue)相关。这些概念在前端开发中尤其重要,特别是在处理异步事件和回调函数时。下面我将解释这些概念,并提供一些代码示例。 事件循环(Event L
阅读全文
摘要:{ type: 'line', ..... endLabel: { show: true, offset: [-18, -10], color: '#ff0000', fontSize:14, formatter: (params) => { return '趋势线' } }, }
阅读全文
摘要:如果,想要做y轴label hover后后面出现图表,文字高亮,主要使用的是yAxis.axisLabel.formatter, yAxis.axisLabel.formatter, 配合echarts实例的mouseover mouseout事件,通过设置hover类目的索引,来给对应类目设置激活
阅读全文
摘要:如图,想要做可以点击轴label,触发后续事件,上代码: const ref = useRef() const eChartInstance = useRef<any>() eChartInstance.current.on('click', function (params) { if (para
阅读全文
摘要:如↑图,想要滚动效果,主要使用的是dataZoom属性,上代码: dataZoom = [ { id: 'dataZoomY', yAxisIndex: [0], show: true, //是否显示滑动条,不影响使用 type: 'slider', // 这个 dataZoom 组件是 slide
阅读全文
摘要:let dataZoom = [ { id: 'dataZoomY', yAxisIndex: [0], show: true, //是否显示滑动条,不影响使用 type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件 startValue: 0
阅读全文
摘要:1.在线预览pdf文档 https://mozilla.github.io/pdf.js/web/viewer.html?file=https://xxx.com/xxx.pdf http://view.xdocin.com/xdoc?_xdoc=https://xxx.com/xxx.pdf 把文
阅读全文
摘要:function warterDocumentSvg(content, container?: any, width?: number, height?: number, opacity?: string, strokeColor?: string, fontSize?: string, zInde
阅读全文
摘要:css: html,body { overflow:hidden; } 或者js控制: $(window).bind( 'touchmove', function(e){ e.preventDefault(); } );
阅读全文
摘要:1.取出两个数组的不同元素 let a1 = [1, 3, 5, 6]; let a2 = [2, 3, 4, 6]; let arr = a1.concat(a2).filter((v, i, arr) => { return arr.indexOf(v) arr.lastIndexOf(v);
阅读全文
摘要:ES6中import和commonJS中require的区别: 1. import是ES6标准中的模块化解决方案(因为浏览器支持情况不同,项目中本质是使用node中的babel将es6转码为es5再执行,import会被转码为require)。 require是node中遵循CommonJS规范的模
阅读全文
摘要:MutationObserver介绍 当我们想想监听某个DOM发生了更改,可以使用MutationObserver,该API被所有现代浏览器支持。 构造方法 MutationObserver() 创建并返回一个新的 MutationObserver 它会在指定的DOM发生变化时被调用。 方法 dis
阅读全文
摘要:<template> <div class="outer-scroll"> <div class="loading top-box"> 默认隐藏,负一屏,手指下滑即可弹出显示,上滑隐藏 </div> <div class="scroll-box"> <h1>正式内容</h1> </div> </di
阅读全文
摘要:为确保Array每次循环等待上次操作完成,必须在每次循环中使用异步函数 const arr = [1, 2, 3]; async function fn() { await arr.reduce(async (accumulator, currentValue) => { await accumul
阅读全文
摘要:需求: 实现PC及移动端播放HLS流,并且可以自动播放,在页面内部播放及全屏播放功能。 初步:PC及安卓机使用hls.js实现hls流自动播放及全屏非全屏播放 首先使用了hls.js插件,可以实现在PC及安卓机自动播放及全屏和非全屏播放。 但是在苹果手机不支持播放,HLS官网说改库使用了MSE,原文
阅读全文
摘要:1.冒泡排序 冒泡排序通常排在第一位,说明它是排序算法的入门算法,是最简单的一个排序算法,而且必须掌握和理解。 先来看看代码吧: function bubbleSort(arr) { let temp; for (let i = 0, len = arr.length; i < len; i++)
阅读全文
摘要:function inheritPrototype(Cat, Animal) { Cat.prototype = Object.create(Animal.prototype); Cat.prototype.constructor = Cat; } function inheritPrototype(subType, superType) { var proto...
阅读全文
摘要:1.写一个log函数,能在浏览器打印台打印出传递的未知参数。 eg: log('a') > 在浏览器控制台打印 'a', log('abc') > 打印'abc' , log('a', 'b', 'c'.....) >打印'a', 'b', 'c'..... 我当时写的: 然后让用别的方法(不用ar
阅读全文