Created
March 17, 2017 08:42
-
-
Save mogocat/0fae23b2ebb3aadac50a108bf360a5b5 to your computer and use it in GitHub Desktop.
[对象匹配运算符和方括号]#tags:object, match
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 * 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