Vue3---Vue3的setup函数中如何使用路由

<template>
  <div>

  </div>
</template>
<script>
import { defineComponent, getCurrentInstance } from 'vue'

export default defineComponent({
  name: 'About',
  setup(){
    const { ctx } = getCurrentInstance() // ctx:当前实例上下文对象,相当于Vue2中的this
    console.log(ctx.$root.$route)
    console.log(ctx.$root.$router)
    return {}
  }
})
</script>

猜你喜欢

转载自blog.csdn.net/qq_39115469/article/details/113794757