필터 영역 간 데이터

1467 단어 VUE.JSJAVASCRIPT
data: 
 testList: [
        { line: 0, len: 15, from: 1, to: 15 },
        { line: 1, len: 16, from: 16, to: 31 },
        { line: 2, len: 6, from: 32, to: 37 },
        { line: 3, len: 24, from: 38, to: 61 },
        { line: 4, len: 72, from: 62, to: 133 },
        { line: 5, len: 24, from: 134, to: 157 },
        { line: 6, len: 7, from: 158, to: 164 },
        { line: 7, len: 6, from: 165, to: 170 },
        { line: 8, len: 56, from: 171, to: 226 },
        { line: 9, len: 586, from: 227, to: 234 },
        { line: 10, len: 18, from: 235, to: 252 },
        { line: 11, len: 13, from: 253, to: 265 },
        { line: 12, len: 30, from: 266, to: 295 },
        { line: 13, len: 30, from: 296, to: 325 },
        { line: 14, len: 30, from: 326, to: 355 },
        { line: 16, len: 30, from: 356, to: 385 },
        { line: 17, len: 30, from: 385, to: 455 },
        { line: 18, len: 30, from: 456, to: 475 },
        { line: 19, len: 9, from: 476, to: 484 },
        { line: 20, len: 8, from: 485, to: 492 },
        { line: 21, len: 31, from: 493, to: 523 },
        { line: 22, len: 7, from: 524, to: 530 },
        { line: 23, len: 7, from: 531, to: 537 }
      ]


 
methods:
   testFn () {
      let obj = {
        str: 244,
        end: 260
      }
      let list = this.testList.filter(item => item.to >= obj.str)
      list = list.filter(item => item.from <= obj.end)
    }

좋은 웹페이지 즐겨찾기