美文网首页vue
Vue3获取当前路由

Vue3获取当前路由

作者: 六寸光阴丶 | 来源:发表于2020-11-09 04:29 被阅读0次
import { getCurrentInstance } from 'vue'

setup() {
  const { ctx } = getCurrentInstance()
  console.log(ctx.$router.currentRoute.value)
}
import { useRoute } from 'vue-router'
import { toRaw } from 'vue'

setup () {
  const route = useRoute()
  console.log(toRaw(route))
}

相关文章

网友评论

    本文标题:Vue3获取当前路由

    本文链接:https://www.haomeiwen.com/subject/jfgkbktx.html