Getters instead of accessing state directly

This commit is contained in:
Unknown
2019-06-22 20:07:11 +02:00
parent ba47943934
commit 6912a96f21
2 changed files with 10 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ export default {
} }
}, },
created() { created() {
this.categories = this.$store.state.data.resources.map(({ title, slug }) => ({ title, slug })) this.categories = this.$store.getters['data/resources'].map(({ title, slug }) => ({ title, slug }))
} }
} }
</script> </script>

View File

@@ -36,6 +36,8 @@ export const state = () => ({
}) })
export const getters = { export const getters = {
tags: state => state.tags,
resources: state => state.resources,
findResources: state => title => { findResources: state => title => {
return state.resources.find(resource => resource.title.toLowerCase() === title.toLowerCase()) return state.resources.find(resource => resource.title.toLowerCase() === title.toLowerCase())
}, },