路由获取参数

2020-07-02  本文已影响0人  若水亦城空

引用地址

案例
http://192.168.0.107:9528/?token=c3fa66266eab4b89a693f3e24a0547e3&system=aaa#/dashboard
import { urlGet } from '@/utils/index'

引用方法

  const $_GET = urlGet()
  $_GET['token']
$_GET['system']
````````````````````````

## utils/index'
```````````````
/**
 * @param {string} url
 * @returns {Object}
 */
export function urlGet() {
  var parts = window.location.search.substr(1).split('&')
  var $_GET = {}
  for (var i = 0; i < parts.length; i++) {
    var temp = parts[i].split('=')
    $_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1])
  }
  return $_GET
}
````````````````````
上一篇下一篇

猜你喜欢

热点阅读