Last active
December 10, 2018 19:14
-
-
Save andrewhl/da431cf1dc264c57c6c44efd2b385b52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
data: [ | |
{ | |
id: 1, | |
level: 1, | |
parent_id: null, | |
children: [ 4,5 ] | |
}, | |
{ | |
id: 2, | |
level: 1, | |
parent_id: null, | |
children: [ 6 ] | |
}, | |
{ | |
id: 3, | |
level: 1, | |
parent_id: null, | |
children: [] | |
}, | |
{ | |
id: 4, | |
level: 2, | |
parent_id: 1, | |
children: [] | |
}, | |
{ | |
id: 5, | |
level: 2, | |
parent_id: 1, | |
children: [] | |
}, | |
{ | |
id: 6, | |
level: 2, | |
parent_id: 2, | |
children: [] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sample_data from './sample_data'; | |
const state = Object.assign({}, sample_data); | |
const getters = { | |
getLevel: state => level => state.data.filter(item => item.level === level) | |
} | |
export default { | |
namespaced: true, | |
state, | |
getters | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment