URL切割

  export default  {
         // word文档的地址 
        fileIp: 'http://192.168.141.220:22223',
        // word编辑器保存的接口
        iframeWordIp: 'http://192.168.140.209:8000',

        parseQueryString (url) { 
          const urlObject = {}  
          if (/?/.test(url)) {   
              const urlString = url.substring(url.indexOf('?') + 1)  
              const urlArray = urlString.split('&')  
              urlArray.map((data) => {
                const urlItem = data
                const item = urlItem.split('=')  
                urlObject[item[0]] = item[1]  
              } )
             
          } 
          return urlObject
      },
      getQueryString (url, key) {    // url切割
          const queryObject = this.parseQueryString(url)
          if (Object.keys(queryObject).length > 0) {
              return queryObject[key]
          } else {
              return ''
          }
      },
  }                          
   引入 isexisamine对应url中的键值如:http://192.168.141.126:8080/#/MonthReport?id=4c6a3b992a96434786e4f04514c3ef38&isexamine=1&index=0
    import wordIp from '@utils/wordDowload'
const isexamine = wordIp.getQueryString(window.location.hash, 'isexisamine')

  

原文地址:https://www.cnblogs.com/whlBooK/p/11821490.html