RE: RE: Nuxt开发指南
You are viewing a single comment's thread from:

RE: Nuxt开发指南

Words
46
Reading
1 min
Listen
Play
7M

useRoute 返回当前路由, 必须在setup函数、插件或路由中间件中调用。
在Vue组件的模板中,可以使用$route访问路由。

const route = useRoute()  // == $route
console.log(route.path) // '/about'

//获取路径id
$route.params.id

//除了动态参数和查询参数, useRoute() 还提供了以下与当前路由相关的计算引用:
fullPath: URLpathqueryhash
hash: #开头的URL的解码hash部分
matched: 
meta: 
name: 
path: URL
redirectedFrom: 访
@lemooljiang: useRoute 返回当前路由, | Ecency