企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
>[success] # 在setup 中使用 Vue router `import { useRouter, useRoute } from 'vue-router' ` 其中`useRouter` 等同于之前`$router`,`useRoute `等同于之前`$route` ~~~ <template> <div @click="goHome">{{ nameRef }}</div> </template> <script> import { ref } from 'vue' import { useRouter, useRoute } from 'vue-router' export default { name: 'about-page', setup() { const nameRef = ref('about 页面') const router = useRouter() const route = useRoute() const goHome = () => { const query = route.query router.push({ path: '/home', query }) } return { nameRef, goHome, } }, } </script> <style></style> ~~~