Vue3 路由传参与接收参数
传参import { useRouter } from 'vue-router';setup() {//实例化路由const router = useRouter();function changeRoute(id: string) {//路由跳转带参数router.push({path: '/tenantLease/add',query: {id: id,
·
传参
import { useRouter } from 'vue-router';
setup() {
//实例化路由
const router = useRouter();
function changeRoute(id: string) {
//路由跳转带参数
router.push({
path: '/tenantLease/add',
query: {
id: id,
},
});
}
}
接收参数
import { nMounted } from 'vue';
import { useRoute } from 'vue-router';
setup() {
const Route = useRoute(); //获取到值
onMounted(() => {
console.log("获取到的参数", Route.query.id);
});
}
更多推荐
已为社区贡献11条内容
所有评论(0)