我有一个对象像下面我想删除所有键值其中key =“/”下划线过滤对象
let routes = {
'/dashboard': {
name : 'Dashboard',
component : appDashboard,
icon: 'fa fa-dashboard',
subRoutes: {
'/': {
component:appDashEcommerce
},
'/ecommerce': {
name : 'Ecommerce',
component:appDashEcommerce
},
}
},
'/apps': {
name : 'Apps',
component : appAppsPage,
icon : 'fa fa-th',
subRoutes: {
'/': {
component:appInbox
},
'/mailbox': {
name : 'maibox',
component : appInbox,
icon : 'fa fa-th',
}
}
};
我当前的代码
var ret2 = _.omit(routes, function(val, key, object) {
if(_.has(val , 'subRoutes')){
_.omit(val.subRoutes , function(v, k, o) {
return key === '/'
})
}else{
return key === '/' || key === '*'
}
})
console.log(ret2)
难道你有问题还是你刚刚说了你的胸部。 – 2016-09-29 21:47:52
对不起,这是一个问题,你有答案吗? –
我有一个,但它更简单,因为它不使用整个库来实现简单的事情 - > https://jsfiddle.net/qspunug6/1/ – adeneo