-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Directives as functions in Vue 3 #55
Comments
No suggestions? |
@mreduar did you found a solution? |
Unfortunately I did not find a solution, I am still open to a solution. const hasRole = (user, role) => {
const roles = user.roleNames;
return roles.some((userRole) => userRole === role);
};
export { hasRole, ... }; import { hasRole } from '@/utils/generalFunctions';
const user = usePage().props.value.auth.user;;
const isAdmin = hasRole(user, 'admin'); If someone finds a solution, do not hesitate to share it. |
Maybe here issues 54 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I am trying to use the directives as functions in Vue 3, but as Vue 3 with Composition API does not have access to
this.$gates
then I can't find a way to make it work.In their documentation there are examples of this, but it doesn't work in vue 3 as usual.
I have also tried with
But it doesn't work for me.
I am using Laravel Inertia and I implement it as follows
Everything works fine in the template directives, like
v-role
but I would like to be able to use it as functions as well.Any ideas?
The text was updated successfully, but these errors were encountered: