随笔分类 -  Js

摘要:一、AMD (Asynchronous Module Definition) 什么是 AMD? AMD 是一种为浏览器环境设计的模块定义规范。它通过异步加载模块,解决了早期前端开发中 JavaScript 文件依赖关系复杂的问题。 require.js https://requirejs.org/d 阅读全文
posted @ 2024-12-11 16:37 灵火 阅读(143) 评论(0) 推荐(0)
摘要:实现类似 C# orderBy 和 thenBy 的 JavaScript 多字段排序 在开发过程中,我们经常需要对数组数据进行多字段排序。例如,我们可能希望先按姓名排序,如果姓名相同再按年龄排序,最后如果还相同,则按分数排序。这种需求在 C# 中通过 orderBy 和 thenBy 很容易实现。 阅读全文
posted @ 2024-12-09 15:44 灵火 阅读(105) 评论(0) 推荐(0)
摘要:效果如图: JS 如下: $.fn.extend({ pagination: function (opts) { // The default config const _defaultConfig = { page: 1, limit: 10, maxDisplayCount: 5, button 阅读全文
posted @ 2024-06-09 16:03 灵火 阅读(53) 评论(0) 推荐(0)
摘要:备份,后面做个整理 let zoneOverviewData = [] let sortFields = [] const getSortedRows = () => { let rows = [...zoneOverviewData]; const ascFields = sortFields . 阅读全文
posted @ 2024-06-05 11:00 灵火 阅读(41) 评论(1) 推荐(0)
摘要:这是一个简易版的 layui 模块定义和加载模块封装 layui github: https://github.com/layui/layui (function () { "use strict"; // 定义 layui 类 var Layui = function () { this.v = 阅读全文
posted @ 2024-05-09 09:34 灵火 阅读(310) 评论(0) 推荐(0)
摘要:js 获取当前脚本对象 对象类型:HTMLScriptElement // 获取当前脚本对象 var script = document.currentScript; console.log(script); // 获取所有js脚本对象 var jsScripts = doc.scripts; fo 阅读全文
posted @ 2024-05-09 08:50 灵火 阅读(23) 评论(0) 推荐(0)
摘要:// useProxy.js const useProxy = () => { const env_arr = ['document', 'window','navigator', 'localStorage'] const env = {} env_arr.forEach((value, inde 阅读全文
posted @ 2023-10-24 22:54 灵火 阅读(46) 评论(0) 推荐(1)
摘要:js 中 function 其实就是 class,function name 就是 class name; 在方法体中,想要实现继承的效果,可以通过 call 来实现: call 方法更改对象内部 this 的指向; function Animal(name){ this.name = name; 阅读全文
posted @ 2023-09-16 15:31 灵火 阅读(41) 评论(0) 推荐(0)