• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

Property '$route' does not exist on type 'ItemList'. 이 에러는 무엇인가요..?

20.04.19 11:11 작성 조회수 598

0

item-list.vue 파일에 

Property '$route' does not exist on type 'ItemList'. 이와 같은 에러가 발생합니다.

실행은 잘 되고 vs-code를 사용하고 있습니다.

아래 코드에서 $route 부분에 빨간줄이 그어져 있습니다.

@Watch('$store.state.todoList', {deep: true})
    stateUpdate() {
        const statusstring = this.$route.params.status;
        this.initRenderList(status);
   }

답변 1

답변을 작성해보세요.

0

안녕하세요!

$route가 this, 즉 class 내부에 타입이 정의되어 있지 않아 발생하는 typescript warning입니다.

아래와 같이 vue-router에서 type을 수동으로 import해서 해결하실 수 있습니다.

import { Vue } from 'vue-property-decorator'
import 'vue-router/types/vue'

@Component
export default class MyComp extends Vue {
	click() {console.log(this.$route)}
}

자세한 내용은 아래 링크를 참고해 보시기 바랍니다.

https://github.com/nuxt-community/typescript-template/issues/23