zoukankan      html  css  js  c++  java
  • 地址hash值分割处理函数

      因经常使用路由的hash值传参,便对其封装了函数,如下直接调用即可

     1 (function getHashStringArgs() {
     2             //取得查询的hash后?的位置
     3             var position = window.location.hash.indexOf("?");
     4             // 截取?后面的字符串
     5             var hashStrings = (window.location.hash.length > 0 ? window.location.hash.substring(position+1) : ""),
     6             // 用来保存分割的hash对
     7             hashArgs = {},
     8             //取得每一项hash对
     9                 items = hashStrings.length > 0 ? hashStrings.split("&") : [],
    10                 item = null,
    11                 name = null,
    12                 value = null,
    13                 i = 0,
    14                 len = items.length;
    15             //逐个将每一项添加到hashArgs中
    16 
    17             for (i = 0; i < len; i++) {
    18 
    19                 item = items[i].split("=");
    20 
    21                 name = decodeURIComponent(item[0]);
    22 
    23                 value = decodeURIComponent(item[1]);
    24 
    25                 if (name.length > 0) {
    26 
    27                     hashArgs[name] = value;
    28 
    29                 }
    30 
    31             }
    32 
    33             return hashArgs;
    34 
    35         })()
    对内贵有志气,对外贵得人心
  • 相关阅读:
    使用binlog恢复数据
    Xtrabackup增量差量备份
    解压腾讯DB冷备的xb文件
    mysqldump
    xtrabackup备份选项
    MySQL的各种日志
    MySQL的事务相关概念
    LVS(dr)+keepalived
    MeasureSpec学习
    网络通信机制:Socket、TCP/IP、HTTP
  • 原文地址:https://www.cnblogs.com/worldly1013/p/6063018.html
Copyright © 2011-2022 走看看