Passing Props to Route Components not work ? #2345
-
i am following Doc of Passing Props to Route Components my code is : // { path: "/prop-route/users/:id", component: OldUser },
{ path: "/prop-route/users/:id", name:"prop-new", component: NewUser, props: true }, <script setup>
import { ref } from 'vue';
import router from '@/router';
import NewUser from '@/views/PropstoRouteComponent/NewUser.vue';
import OldUser from '@/views/PropstoRouteComponent/OldUser.vue';
const change = ref(true)
</script>
<template>
<li><router-link to="/prop-route/users/332">/prop-route/users/332</router-link></li>
<NewUser></NewUser>
<!-- <OldUser></OldUser> -->
</template> <!-- NewUser.vue -->
<script setup>
import { defineProps } from 'vue';
const props = defineProps({
id: String
})
</script>
<template>
<div>
New User {{ id }}
</div>
</template> <!-- OldUser.vue -->
<template>
<div>
Old User {{ $route.params.id }}
</div>
</template> package.json "dependencies": {
"vue": "^3.4.29",
"vue-router": "^4.3.3"
}, in OldUser component work good . i had reference some solution but still not work.
|
Beta Was this translation helpful? Give feedback.
Answered by
leo41271
Aug 26, 2024
Replies: 1 comment
-
i finally found my mistake
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
leo41271
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i finally found my mistake