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
|
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 { createMenu } from '../libs/util.menu'
|
||||||
import BScroll from 'better-scroll'
|
import BScroll from 'better-scroll'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染侧栏菜单
|
||||||
|
*/
|
||||||
export default {
|
export default {
|
||||||
name: 'd2-layout-header-aside-menu-side',
|
name: 'd2-layout-header-aside-menu-side',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
|
|
@ -369,6 +369,7 @@ export default {
|
||||||
state.current = fullPath
|
state.current = fullPath
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
* 路由池
|
||||||
* @class pool
|
* @class pool
|
||||||
* @description 保存 pool (候选池)
|
* @description 保存 pool (候选池)
|
||||||
* @param {Object} state state
|
* @param {Object} state state
|
||||||
|
@ -378,6 +379,7 @@ export default {
|
||||||
const pool = []
|
const pool = []
|
||||||
const push = function (routes) {
|
const push = function (routes) {
|
||||||
routes.forEach(route => {
|
routes.forEach(route => {
|
||||||
|
console.log('=========================== app handle router ===========================', route)
|
||||||
if (route.children && route.children.length > 0) {
|
if (route.children && route.children.length > 0) {
|
||||||
push(route.children)
|
push(route.children)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue