vue-typescript-admin-template 中添加module没有挂载在store上 想问下是怎么回事?

vue-typescript-admin-template 中添加module没有挂载在store上 想问下是怎么回事?

模板上可以挂载在stroe上的代码如下

import { VuexModule, Module, Mutation, Action, getModule } from 'vuex-module-decorators'

import store from '@/store'

@Module({ dynamic: true, store, name: 'permission' })

class Permission extends VuexModule implements IPermissionState {

public routes: RouteConfig[] = []

public dynamicRoutes: RouteConfig[] = []

@Mutation

private SET_ROUTES(routes: RouteConfig[]) {

this.routes = constantRoutes.concat(routes)

console.log(this.routes);

router.addRoutes(routes)

this.dynamicRoutes = routes

}

@Action

public GenerateRoutes() {

const menus:Imenus[] = UserModule.menus;

let accessedRoutes:RouteConfig[]=[]

const r = bcd(asyncRoutes,menus)

accessedRoutes= [...accessedRoutes,...r]

this.SET_ROUTES(accessedRoutes)

}

}

export const PermissionModule = getModule(Permission)

自己写的代码如下

import { VuexModule, Module, Action, getModule } from 'vuex-module-decorators'

import {

GetAuditLdogs,

GetAuditLogsDetail,

GetEntityChanges,

} from "@/api/AuditLogMange";

import store from '@/store'

export interface IAuditLogManageState {}

@Module({dynamic: true, store, name: "auditlog",namespaced:true })

class AuditLogManagemode extends VuexModule implements IAuditLogManageState {

@Action

public async GetAuditLdogs(payload: any) {

const reponse = await GetAuditLdogs(payload.data);

return reponse;

}

@Action

public async GetEntityChanges(payload: any) {

const reponse = await GetEntityChanges(payload.data);

return reponse;

}

@Action

public async GetAuditLogsDetail(payload: any) {

const reponse = await GetAuditLogsDetail(payload.data);

return reponse;

}

}

export const AuditLogManageModule = getModule(AuditLogManagemode);

store目录下的index.ts如下

import Vue from 'vue'

import Vuex from 'vuex'

import { IUserState } from './modules/user'

import { IAppState } from "./modules/app";

import { ITagsViewState } from './modules/tags-view'

import { IPermissionState } from './modules/permission'

Vue.use(Vuex)

export interface IRootState {

}

export default new Vuex.Store<IRootState>({})

以上是 vue-typescript-admin-template 中添加module没有挂载在store上 想问下是怎么回事? 的全部内容, 来源链接: utcz.com/p/935697.html

回到顶部