Difference between this.$store.state.search.query and this.$store.getters['search/getQuery']
steve last edited by
I understand that state is a set value and getters are/can be condition on the state value.
Is that the only reason to choose between dot notation and a getter? Are there any other benefits or best practices in using one over the other?
Zyme last edited by
I looked into this issue recently and the conclusion I came to was this:
Both return the same value if you are just accessing raw data. But a getter can manipulate the data before passing it along.
If you are accessing the state directly throughout your app on many places, and you want to manipulate the data, for example change the number formatting or whatever. It wil become a pain to change it on all places.
If you used a getter you only change this in one place.