vue3 useRoute与useRouter 区别
useRouter(跳转), useRoute(获取路由参数)import { useRoute, useRouter } from 'vue-router';...if (route.query?.redirect) { // route 获取路由参数router.push({path: <string>route.query?.redirect,query: Object.keys
·
useRouter(跳转), useRoute(获取路由参数)
import { useRoute, useRouter } from 'vue-router';
...
if (route.query?.redirect) { // route 获取路由参数
router.push({
path: <string>route.query?.redirect,
query: Object.keys(<string>route.query?.params).length > 0 ? JSON.parse(<string>route.query?.params) : '',
});
} else {
// 跳转 设置重定向路由路径
router.push('/');
}
更多推荐
已为社区贡献2条内容
所有评论(0)