vue3点击跳转页面

时间:2025-02-07 13:18:22
在点击事件的页面 <template> <button @click="jump">按钮跳转</button> <router-view></router-view> </template> <script> import {useStore} from '@/store/index' //先是引入useRouter import {useRouter} from 'vue-router' export default { setup(){ const store = useStore() const router = useRouter() //通过定义一个方法,使用router进行跳转,这里后面的123是路由传参,不传可以不加 const jump =()=>{ router.push('/testHome/123') } return { store, //这里暴露一下jump方法 jump } } } </script>