inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

Typescript with Vue 실전 프로젝트

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

861

esquared

작성한 질문수 2

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);
   }

vuejs

답변 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

소스 공유좀 해주세요

0

251

0

target null 에러뜨시는 분들

0

329

0

라우터 구조잡기 소스

0

284

0

새로 추가한 인스턴스 상태 관리

0

245

0

App.vue의 $store

0

192

0

npm run serve 에러

0

220

0

Cannot find module '@/components/message.vue' or its corresponding type declarations.

0

1150

2

prop !

0

193

0

@ MutationActions

0

177

0

mapGetters 내 정의가 안되요 ㅠ

0

259

0

안녕하세요! @Prop() readonly id(느낌표):string; 에서 !(느낌표) 를 찍는 이유가 궁금합니다 :)

0

224

0

store 사용 방법 관련 질문입니다.

0

239

1

moduleA.store.ts내에서 RootState가 하는일은 무엇인가요?

0

178

0

removeItem 에서 element 가 하나 남았을 때 삭제가 되지 않는 문제

0

369

2

Cannot find module '@/components/message.vue'.

0

2869

6

@Action, @Mutation 등으로 지정된 변수의 타입

0

227

1

안녕하세요. 강의 잘 들었습니다.

0

166

0

Axios Post보낼때 어떤 식으로 구성하는게 좋을까요?

0

660

1

안녕하세요! v-for(v-bind:key), slice() 관련 질문이 있어요!

2

666

3

에러 표시 질문이요!

1

402

3

vuex-module-decorators 보다 오리지널 모듈 형태를 선호하시는 이유가 무엇이신가요?

1

377

2

안녕하세요. 초기 셋팅시 질문있습니다.

1

294

2

안녕하세요! Vuex, actions 질문이 있습니다.

1

302

2

클래스 속성 에러는 무엇인가요??

1

171

1