搬砖大老
搬砖大老
  • 发布:2023-09-13 11:00
  • 更新:2023-09-13 11:00
  • 阅读:1493

uni可用的new URL(),直接获取url中的参数等信息

分类:uni-app

插件传送门 uni可用的new URL()

// 从自己所放到路径引入,检查路径和文件名是否正确,错误请自己修改  
import URL from '@/js_sdk/cainiao-url/url.js'  

const url = new URL('https://www.aaa.com:8989/bbb/ccc/ddd.html?e=1&f=2&g#h=3&i=4&j?k=5#l=6&e=4')  

console.log(url)
{  
  "href": "https://www.aaa.com:8989/bbb/ccc/ddd.html?e=1&f=2&g#h=3&i=4&j?k=5#l=6&e=4",  
  "origin": "https://www.aaa.com",  
  "protocol": "https:",  
  "host": "www.aaa.com",  
  "port": "8989",  
  "pathname": "/bbb/ccc/ddd.html",  
  "search": "?e=1&f=2&g&k=5",  
  "hash": "#h=3&i=4&j&l=6&e=4",  
  "params": {  
    "h": "3",  
    "i": "4",  
    "l": "6",  
    "e": "1",  
    "f": "2",  
    "k": "5"  
  }  
}
0 关注 分享

要回复文章请先登录注册