Merge remote-tracking branch 'origin/master'
# Conflicts: # web/src/main.js # web/src/menu/index.js # web/src/router/index.js # web/src/store/modules/d2admin/modules/account.js
This commit is contained in:
commit
774b4168ab
|
@ -96,4 +96,45 @@ web/src/api/service.js
|
|||
router > api
|
||||
```
|
||||
|
||||
### store 例子
|
||||
```vue
|
||||
// store/index.js
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
count: 0,
|
||||
// 其他状态...
|
||||
},
|
||||
mutations: {
|
||||
increment(state) {
|
||||
state.count++
|
||||
},
|
||||
// 其他 mutation 函数...
|
||||
},
|
||||
actions: {
|
||||
// 可能包含异步操作的 action 函数...
|
||||
},
|
||||
getters: {
|
||||
getCount: state => state.count,
|
||||
// 其他 getter 函数...
|
||||
}
|
||||
})
|
||||
```
|
||||
```vue
|
||||
// 在任何一个 Vue 组件中,你就可以通过 this.$store 访问 Vuex store
|
||||
// 任意Vue组件内部
|
||||
export default {
|
||||
mounted() {
|
||||
console.log(this.$store.state.count) // 访问状态
|
||||
this.$store.commit('increment') // 提交 mutation 更新状态
|
||||
this.$store.dispatch('someAction') // 分发 action
|
||||
const count = this.$store.getters.getCount // 获取 getter 数据
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@ import menuMixin from '../mixin/menu'
|
|||
import { createMenu } from '../libs/util.menu'
|
||||
import BScroll from 'better-scroll'
|
||||
|
||||
/**
|
||||
* 渲染侧栏菜单
|
||||
*/
|
||||
export default {
|
||||
name: 'd2-layout-header-aside-menu-side',
|
||||
mixins: [
|
||||
|
|
|
@ -369,6 +369,7 @@ export default {
|
|||
state.current = fullPath
|
||||
},
|
||||
/**
|
||||
* 路由池
|
||||
* @class pool
|
||||
* @description 保存 pool (候选池)
|
||||
* @param {Object} state state
|
||||
|
@ -378,6 +379,7 @@ export default {
|
|||
const pool = []
|
||||
const push = function (routes) {
|
||||
routes.forEach(route => {
|
||||
console.log('=========================== app handle router ===========================', route)
|
||||
if (route.children && route.children.length > 0) {
|
||||
push(route.children)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue