过滤器
filter() 方法创建一个新的数组,新数组中的元素是通过检查指定数组中符合条件的所有元素。
用法:
定义一个数组options:

options: [
        { text: 'One', value: 'A' },
        { text: 'Two', value: 'B' },
        { text: 'Three', value: 'C' }
      ],

如果想过滤text为Two的数据 只需要

this.options.filter(item => {
  return item.text === 'Two';
})

一定要有return返回值

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐