正则,转换数组
const defaultConfig = [ { key: 'my-info', name: '我的资料', isShow: true, isAct: false, noHeader: false, children: [ { key: '', name: '基本资料', isAct: false }, { key: 'change-avator', name: '修改头像', isAct: false }, { key: 'change-pwd', name: '修改密码', isAct: false }, { key: 'change-name', name: '修改昵称', isAct: false }, { key: 'realname', name: '实名认证', isAct: false }, { key: 'change-phone', name: '绑定手机', isAct: false }, { key: 'change-email', name: '修改邮箱', isAct: false } ] }, { key: 'my-msg', name: '我的消息', isShow: true, isAct: false, noHeader: false, children: [ { key: '', name: '', isAct: false }, { key: 'guild', name: '', isAct: false } ] }, { key: 'my-wealth', name: '我的财富', isShow: true, isAct: false, noHeader: false }, { key: 'my-follow', name: '我的关注', isShow: true, isAct: false, noHeader: false }, { key: 'my-order', name: '视频订单', isShow: true, isAct: false, noHeader: false }, { key: 'my-history', name: '观看历史', isShow: true, isAct: false, noHeader: false }, { key: 'my-appointment', name: '赛事预约', isShow: true, isAct: false, noHeader: false }, { key: 'my-card', name: '我的卡券', isShow: false, isAct: false, noHeader: false }, { key: 'my-guess', name: '我的趣猜', isShow: true, isAct: false, noHeader: false }, { key: 'my-medal', name: '我的奖牌', isShow: true, isAct: false, noHeader: false }, { key: 'my-upload', name: '我的投稿', isShow: true, isAct: false, noHeader: false }, { key: 'my-collection', name: '视频收藏', isShow: true, isAct: false, noHeader: false }, { key: 'room-manger', name: '房间管理', isShow: true, isAct: false, noHeader: false }, { key: 'realname-verify', name: '实名认证', isShow: true, isAct: false, noHeader: false }, { key: 'anchor-guild', name: '主播公会', isShow: true, isAct: false, noHeader: true }, { key: 'room-setting', name: '直播设置', isShow: true, isAct: false, noHeader: false, children: [ { key: '', name: '房间设置', isAct: false }, { key: 'room-admin', name: '管理员', isAct: false }, { key: 'blacklist', name: '黑名单', isAct: false }, { key: 'ipban', name: '屏蔽IP', isAct: false } ] }, { key: 'room-special', name: '主播专用', isShow: true, isAct: false, noHeader: false, children: [ { key: '', name: '预约比赛', isAct: false }, { key: 'record', name: '直播记录', isAct: false }, { key: 'profit', name: '直播收益', isAct: false }, { key: 'draw', name: '抽奖记录', isAct: false }, { key: 'convert', name: '', isAct: false } ] }, { key: 'guess-manage', name: '趣猜管理', isShow: true, isAct: false, noHeader: false }, { key: 'guild-manage', name: '公会管理', isShow: true, isAct: false, noHeader: true }, { key: 'guessexpert', name: '比赛预测', isShow: true, isAct: false, noHeader: true }, { key: 'apply-live', name: '申请直播', isShow: true, isAct: false, noHeader: false } ]; let a = defaultConfig.map(c=>c.key.replace(/-(\w)/,function ($0,$1){ // $0 => -x; $1 => x return $1.toUpperCase(); })+'RootSaga') // ["myInfoRootSaga","myMsgRootSaga","myWealthRootSaga","myFollowRootSaga","myOrderRootSaga","myHistoryRootSaga","myAppointmentRootSaga","myCardRootSaga","myGuessRootSaga","myMedalRootSaga","myUploadRootSaga","myCollectionRootSaga","roomMangerRootSaga","realnameVerifyRootSaga","anchorGuildRootSaga","roomSettingRootSaga","roomSpecialRootSaga","guessManageRootSaga","guildManageRootSaga","guessexpertRootSaga","applyLiveRootSaga"]