zoukankan      html  css  js  c++  java
  • 前端-常用函数记录-持续更新

    // 获取当前路径下?问号后边的值
    GetQueryString = function (name) { const reg = new RegExp (`(^|&)${name}=([^&]*)(&|$)`); const href = window.location.href; const index = href.indexOf('?'); const r = href.substr(index + 1).match (reg); if (r != null) return unescape (r[2]); return null; };
    调用示例:
      获取
    “https://www.google.com/search?q=baidu” 这个路径 “q” 后面的 “baibu
      templateId('q');
      "baidu"
    // 全局唯一ID函数 uuid
    GetUuid = function () {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace (/[xy]/g, c => { let r = (Math.random () * 16) | 0; let v = c == 'x' ? r : (r & 0x3) | 0x8; return v.toString (16); }); }
    调用示例:
      GetUUid();
      "327aaf38-c195-4000-b5c4-d36bf9b2894e"
    // 对象数组去重
    arrayUnique = function (songs) { const result = {}; const finalResult = []; for (let i = songs.length - 1; i >= 0; i--) { result[songs[i].name] = songs[i]; } Object.keys(result).map((item) => finalResult.push(result[item])); return finalResult; }

    // 拉取某个文件夹下面的所有文件
    loadAllFile = function ('filePath','fileExp') {     const filesMD = require.context(filePath, true,fileExp); return filesMD.keys(); }
  • 相关阅读:
    ServiceHelperWindows服务辅助类
    .NET代码生成工具
    在同一个表内显示数据分级
    每天坚持要做的事情
    使用NCover协同NUnit一起工作
    Nant学习总结
    我的新家
    问题(待解决):ISNULL 的使用问题
    问题:String or binary data would be truncated
    问题:关于WCF
  • 原文地址:https://www.cnblogs.com/ChineseLiao/p/12979806.html
Copyright © 2011-2022 走看看