Skip to content

Instantly share code, notes, and snippets.

@harrybeckwith
Last active July 23, 2019 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harrybeckwith/08718c3a576ea6b21efe695e579a7ddf to your computer and use it in GitHub Desktop.
Save harrybeckwith/08718c3a576ea6b21efe695e579a7ddf to your computer and use it in GitHub Desktop.
mapGetters and mapState
<template>
<div>
<h1>Create Event {{ userName }}</h1>
<p>There are {{catLength}} categories</p>
<ul>
<li v-for="cat in categories" :key="cat">
{{cat}}
</li>
</ul>
<p>
{{ getEventById(3) }}
</p>
</div>
</template>
<script>
import { mapState, mapGetters } from 'vuex'
export default {
computed: {
...mapState(['user', 'categories']),
...mapGetters(['getEventById', 'catLength'])
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment