- 39
- 0
以下是我目前的实现方式,无法解决这个问题
我想以 this.$const.color.red 获取CommonConst 类中的red常量和以
this.$const.routerName.login的方式获取RouterName 类中的login;
但因为typescript是单继承,所以我只能让Constants 类继承一个CommonConst ,不能将CommonConst和RouterName 一起继承
同时希望以面向对象的方式实现,编辑器可以通过类型提示出来 我输 this.$const.routerName.的时候就能提示出来routerName类中的所有属性
export default class RouterName {
public static login: string = 'login'
public static authentication: string = 'authentication'
public static search: string = 'search'
public static home: string = 'home'
public static talkList: string = 'talkList'
public static voice: string = 'voice'
public static voiceList: string = 'voiceList'
public static chat: string = 'chat'
public static message: string = 'message'
public static userDetail: string = 'userDetail'
public static match: string = 'match'
public static talkDetail: string = 'talkDetail'
public static notify: string = 'notify'
public static mine: string = 'mine'
public static talkAdd: string = 'talkAdd'
}
export default class CommonConst {
public static colorObj: Object = {
1: 'red',
2: 'pink',
3: 'purple',
4: 'blue',
5: 'teal',
6: 'green',
7: 'indigo',
8: 'orange',
9: 'brown',
}
}
export default class Constants extends CommonConst {
public static readonly sexList: Array<EnumVO> = [new EnumVO(1, '男'), new EnumVO(2, '女')]
public static readonly simpleDate: string = 'YYYY-MM-DD'
public static readonly regNotNum: RegExp = reg.regNotNum
public static readonly routerName: any = RouterName
}
import Constants from './constants'
export default (Vue) => {
Vue.prototype.$const = Constants
}
2
打赏
收藏
点击回答
您的回答被采纳后将获得:提问者悬赏的 11 元积分
网站公告
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
