Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In Vuex
- import _ from 'lodash'
- const state = {
- users: []
- }
- const getters = {
- userGroup (state) {
- return _.groupBy(state.users, 'title') // using lodash groupBy, https://lodash.com/docs/4.17.11#groupBy
- }
- }
- const actions = {
- getUser () {
- axios.get('/')
- }
- }
- export default {
- state, getters, actions
- }
- // In Component
- export default {
- data () => ({
- }),
- computed: {
- group () {
- return this.$store.getters.userGroup
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment