Skip to main content

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)

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.