itsource

Vue 2: "속성을 읽을 수 없습니다"

mycopycode 2022. 8. 29. 22:24
반응형

Vue 2: "속성을 읽을 수 없습니다"

방금 앱을 Vue 2로 업그레이드했는데 이 오류를 벗어날 수 없습니다.

"Uncatched TypeError: VueComponent에서 null 속성 'length'를 읽을 수 없습니다.show Choices (평가: (app.js:310), :33:32)

조건부로 보호하고 있다고 생각했는데, 이 에러가 3시간째 신경이 쓰이고 있습니다.show Choices:

showChoices() {
    if(this.filtered) {
        if (this.search.length > 2 && this.filtered.length > 0) {
            return true;
        }
    }
    return false;
}

A null값에는 a가 없습니다.length소유물.코멘트대로this.searchnull 입니다.이거 하려고 한 거 아니야?

showChoices() {
  if (this.search && this.filtered) {
    if (this.search.length > 2 && this.filtered.length > 0) {
        return true;
    }
  }
  return false;
}

다음과 같이 늘 검사도 추가해야 합니다.

showChoices() {
    if (this.search && this.search.length > 2 && this.filtered && this.filtered.length > 0) {
      return true;
    }
    return false;
}

언급URL : https://stackoverflow.com/questions/41662546/vue-2-cant-get-past-cannot-read-property

반응형