vue获取路径
获取当前完整路径 : window.location.href
获取路由路径: this.$route.path
获取路由参数:this.$route.params
获取路由查询参数:this.$route.query
小程序获取路径
// 获取当前路径
var pages = getCurrentPages() //加载的页面
var currentPage = pages[pages.length - 1] //获取当前页面的对象
var url = currentPage.route
var options = currentPage.options //url中传的参数
console.log(pages, currentPage, url, options ) //url即为当前路径
Javascript获取路径
获取当前窗口url:window.location.href
获取当前主机名:window.location.host
获取当前窗口的端口:window.location.port
获取当前窗口路径: window.location.pathname
获取当前文档的url:window.location.URL
获取参数:window.location.search