In Vue 3, how to get $page.props value in setup() ? #505
Answered
by
reinink
sarukomine
asked this question in
Help (Vue)
-
Hi, I am new, I have read the doc (https://inertiajs.com/shared-data), but it only teaching how use $page.props in I tried below but not working. It says export default {
setup() {
const user = $page.props.user
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
reinink
Feb 18, 2021
Replies: 1 comment 3 replies
-
Yeah, we need to add the <template>
<div>Logged in as: {{ user.name }}</div>
</template>
<script>
import { computed } from 'vue'
import { usePage } from '@inertiajs/inertia-vue3'
export default {
setup() {
const user = computed(() => usePage().props.value.user)
return { user }
},
}
</script> |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
claudiodekker
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, we need to add the
usePage()
hook to the docs still. Here's how to do this: