davestewart / vuex-pathify

Vue / Vuex plugin providing a unified path syntax to Vuex stores
https://davestewart.github.io/vuex-pathify
MIT License
1.37k stars 57 forks source link

How to reference this (Vue instance) #62

Closed haexhub closed 5 years ago

haexhub commented 5 years ago

Hi,

I would like to know, how to refer to the Vue instance in computed properties.

this works

  computed: {
    menu: sync('fancy_module/menus@navigation.items')
  }

this not

  data () {
    return {
      foobar: 'fancy_module/menus@navigation.items'
    }
  }

, computed: {
    menu: sync(this.foobar)
  }

this is not referencing to Vue. I know that arrow functions bring a new this context. But I don't use it here, do I? Any advie would be great.

davestewart commented 5 years ago

Hey @haexhub

This seems to come up a lot, so I'll probably add some documentation on how to handle this.

In the meantime, see this issue and the comments / links:

https://github.com/davestewart/vuex-pathify/issues/28

I think I might add a helper as well, so this kind of thing is easy.