Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Front-end Permissions: Show/Hide Buttons

Premium
3 min read

Comments & Discussion

V
Vitalii ✓ Link copied!

I think there's a typo: we should use page.props.permissions instead of page.props.auth.permissions here

const can = (permission) => { return page.props.permissions.includes(permission) }

DL
David Lun ✓ Link copied!

why do you think that way?

JG
Jakub Gazdowicz ✓ Link copied!

Hello, how can i use this can() method in 'script' section? For example i have AppMenu.vue component in which i manage my menu buttons for routing, and i want to hide some of them depends on permission. This example throws undefined error and i don't understand why. (rewrite to export default function can() solves this problem - works in script and template)