Skip to content
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

TypeError: Cannot read properties of undefined (reading 'setPermissions') in Nuxt.js #61

Open
yudanf93 opened this issue Jul 17, 2023 · 0 comments

Comments

@yudanf93
Copy link

` const role = this.$store.state.role.roles
const user = ['user']

        const roleJson = JSON.stringify(role)
        const userJson = JSON.stringify(user)
        if (roleJson === userJson) {
            this.$gates.setPermissions([
                'view sales',
                'add sales',
                'edit sales',
                'delete sales',
                'import sales',
                'summary report',
                'product report',
                'daily sale report',
                'monthly sale report',
                'daily purchase report',
                'sale report',
                'purchase report',
                'warehouse report',
                'product qty alert',
                'customer report',
                'supplier report',
                'due report',
                'pos'
            ])
            console.log(this.$gates)
        }`

<button v-permission="'add sales'">Add Sales</button>

setting in plugins/vue-gates.js
`import Vue from 'vue'
import VueGates from 'vue-gates'

Vue.use(VueGates)

export default (_context, inject) => {
inject('gates', Vue.prototype.$gates)
}`

someone please help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant