leonardovilarinho / vue-acl

Access Control List plugin for VueJS 2.0
375 stars 76 forks source link

Computed property not working #59

Closed jsinhSolanki closed 5 years ago

jsinhSolanki commented 5 years ago

Hi there,

I want to display sidebar item conditionally so I have v-if in template tag. But computed property is not reactive??

<div ... v-if="canSee">
..
</div>
    computed: {
        canSee() {
                       console.log('test);
                return this.$acl.check(this.$router.match(this.to).meta.rule)
        }
    },

test is only logged for first time. When I change role using radio button, computed property is not recalculated???

I tested it again. Actually it's not updating state in my component. {{ $acl.get[0] }} this is not working in that component. However in other page it works.

leonardovilarinho commented 5 years ago

I created a method of doing something similar in commit b9e96f0f6bdadc060d8ea18030dbb95634084091. Use the following code:

mounted () {
  this.$acl.onChange = newPermission => {
    console.log('Has changed to', newPermission)
  }
}