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>({})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论