一个 string[] 即数组对象,怎么去掉符合条件的多个对象?

新手上路,请多包涵

columns = [

{
  title: '序号',
  dataIndex: 'id',
},
{
  title: '环境',
  dataIndex: 'environment'
},
{
  title: '配置名称',
  dataIndex: 'configName'
},
{
  title: '账号',// 账号配置
  dataIndex: 'userName'
},
{
  title: '日志分组',// 采集回放配置
  dataIndex: 'logStore'
},
{
  title: '账号类型',// 账号配置
  dataIndex: 'endUserType',
},
{
  title: '登陆地址',// 登陆配置
  dataIndex: 'loginUrl'
},
{
  title: '访问地址',// 访问地址配置
  dataIndex: 'url'
},
{
  title: '历史版本',
  dataIndex: 'gmtCreate',
  width: '18%',
},
{
  title: '创建时间',
  dataIndex: 'gmtCreate'
}

];
一个数组columns, 怎么去掉dataIndex="url"和dataIndex="logStore",得到一个新的数组
columns = [

{
  title: '序号',
  dataIndex: 'id',
},
{
  title: '环境',
  dataIndex: 'environment'
},
{
  title: '配置名称',
  dataIndex: 'configName'
},
{
  title: '账号',// 账号配置
  dataIndex: 'userName'
},
{
  title: '账号类型',// 账号配置
  dataIndex: 'endUserType',
},
{
  title: '登陆地址',// 登陆配置
  dataIndex: 'loginUrl'
},
{
  title: '历史版本',
  dataIndex: 'gmtCreate',
  width: '18%',
},
{
  title: '创建时间',
  dataIndex: 'gmtCreate'
}

];

阅读 1.6k
1 个回答
const newColumns = columns.filter((v) => v.dataIndex !== 'url' && v.dataIndex !== 'logStore')
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题