前端页面的连接通过页面跳转,有时候需要解析url地址传递的参数,记录方法,
完整url可以用 window.location.href
路由路径可以用 this.
r
o
u
t
e
.
p
a
t
h
路
由
路
径
参
数
t
h
i
s
.
route.path 路由路径参数 this.
route.path路由路径参数this.route.params 例如:/videoLearn/:course_id→ /videoLearn/1234567 → this.
r
o
u
t
e
.
p
a
r
a
m
s
.
c
o
u
r
s
e
i
d
路
由
查
询
参
数
t
h
i
s
.
route.params.course_id 路由查询参数 this.
route.params.courseid路由查询参数this.route.query 例如:/user/search?course_id=1234567→ this.$route.query.course_id
前端vue解析url地址
最新推荐文章于 2025-10-30 09:36:07 发布
在前端开发中,使用Vue.js时,经常需要解析URL地址来获取路径或查询参数。可以使用`window.location.href`获取完整URL,`this.route.path`获取路由路径,以及`this.route.params`和`this.route.query`来分别获取路由参数和查询参数。

4386

被折叠的 条评论
为什么被折叠?



