首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

JS获取当前网址信息

通过window.location对象获取对应的属性 1、设置或获取对象指定的文件名或路径(pathname) window.location.pathname 2、设置或获取整个 URL 为字符串(href...) window.kk 3、设置或获取与 URL 关联的端口号码(port) window.location.port 4、设置或获取 URL 的协议部分(protocol) window.location.protocol...设置或获取 href 属性中在井号“#”后面的分段(hash) window.location.hash 设置或获取 location 或 URL 的 hostname 和 port 号码(host)...window.location.host 设置或获取 href 属性中跟在问号后面的部分(search) window.location.search 获取变量的值(截取等号后面的部分) window.location.search.substring...2、通过正则表达式准确的获取我们需要的参数

13.7K30
您找到你想要的搜索结果了吗?
是的
没有找到

Vue获取url网址参数的两种方法

Vue 有两种方法可以方便地获取 url 的参数: 一种是在路由中配置了 path : {     path: '/detail/:id/',     name: 'detail',     component...: detail,     meta: {         title: '详情'     } } 获取参数: let id = this....$route.params.id 注意: 1、参数名需要保持一致 2、如果路由中没有传参(https://w3h5.com/detail),会报错页面无法显示。...正常链接应该为 https://w3h5.com/detail/234 如果有的参数可传可不传,可以使用 ? 传参: https://w3h5.com/detail?...id=168 获取方法: let id = this.$route.query.id 这样即使取不到参数,页面也不会报错。 可以根据自己的需求使用不同的方法获取 url 参数

26.9K30
领券