Skip to content

Instantly share code, notes, and snippets.

@mogocat
Created March 17, 2017 08:42
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 mogocat/0fae23b2ebb3aadac50a108bf360a5b5 to your computer and use it in GitHub Desktop.
Save mogocat/0fae23b2ebb3aadac50a108bf360a5b5 to your computer and use it in GitHub Desktop.
[对象匹配运算符和方括号]#tags:object, match
// import * as http from '../../http/test'
// import axios from 'axios'
import service from '../../services/category-service'
import * as types from '../mutation-types'
import lib from '@/components/lib'
const state = {
nodeList: [],
currentNode: {}
}
const getters = {
nodeTree(state){
console.log(state.nodeList)
console.log(lib.listToTree(state.nodeList))
return lib.listToTree(state.nodeList)
}
}
const actions = {
LoadCategoryTree({commit}) {
service.LoadCategoryTree(tree => {
commit(types.LOAD_CATEGORY_TREE, {
tree
})
})
}
}
const mutations = {
[types.LOAD_CATEGORY_TREE](state, {tree}){
state.nodeList = tree
},
[types.CHOOSE_CATEGORY_NODE](state, {id}){
console.log(id)
}
}
export default{
state,
getters,
actions,
mutations
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment