안녕하세요? @Prop 관련 질문좀..ㅠㅠ
227
작성한 질문수 8
템플릿은.
<template v-if="todoData.length">
<Item v-for="todo in todoData" :todoItem="todo"/>
</template>
위와 같구요.
@Component({
components: {ItemInput, Header, Item},
})
export default class TodoList extends Vue {
public todoData: any[] = [{id: 0, title: 'test', status: 'active'}, {id: 1, title: 'test', status: 'clear'}, {id: 2, title: 'test', status: 'clear'}];
}
스크립트 부분에서는 이렇게 초기화를 해줍니다.
그러면 3개가 들어있으니 3번 반복까지는 되는데
자식 컴포넌트에서 저 값을 받지를 못합니다..
props 로 하면 잘 됬던걸로 기억하는데.. 이부분도 제가 TS 지식이 부족해서 그런거 같기도하고 ㅠㅠ
import {Component, Prop, Vue} from 'vue-property-decorator';
export default class Item extends Vue {
@Prop() public readonly todoItem!: object | undefined;
public changeStatus() {
console.log(this.todoItem);
}
public removeItem() {
}
}
자식에서는 위와 같이 쓰는데..
저기에 빈 객체로 초기화를 해줘도 잘 안되네요 ㅠㅠ
도와주세요!
답변 2
1
안녕하세요, 님!
작성하신 코드를 보았는데요.
자식 컴포넌트에서 @Component 데코레이터를 사용하지 않아서 발생하는 문제로 보입니다.
아래 코드와 같이 데코레이터를 사용해주세요 ^^
@Component
export default class Item extends Vue {
@Prop()
readonly todoItem!: any;
}
소스 공유좀 해주세요
0
252
0
target null 에러뜨시는 분들
0
330
0
라우터 구조잡기 소스
0
285
0
새로 추가한 인스턴스 상태 관리
0
247
0
App.vue의 $store
0
192
0
npm run serve 에러
0
221
0
Cannot find module '@/components/message.vue' or its corresponding type declarations.
0
1152
2
prop !
0
194
0
@ MutationActions
0
179
0
mapGetters 내 정의가 안되요 ㅠ
0
260
0
안녕하세요! @Prop() readonly id(느낌표):string; 에서 !(느낌표) 를 찍는 이유가 궁금합니다 :)
0
227
0
store 사용 방법 관련 질문입니다.
0
240
1
moduleA.store.ts내에서 RootState가 하는일은 무엇인가요?
0
179
0
removeItem 에서 element 가 하나 남았을 때 삭제가 되지 않는 문제
0
373
2
Property '$route' does not exist on type 'ItemList'. 이 에러는 무엇인가요..?
0
862
1
Cannot find module '@/components/message.vue'.
0
2870
6
@Action, @Mutation 등으로 지정된 변수의 타입
0
227
1
안녕하세요. 강의 잘 들었습니다.
0
168
0
Axios Post보낼때 어떤 식으로 구성하는게 좋을까요?
0
663
1
안녕하세요! v-for(v-bind:key), slice() 관련 질문이 있어요!
2
667
3
에러 표시 질문이요!
1
403
3
vuex-module-decorators 보다 오리지널 모듈 형태를 선호하시는 이유가 무엇이신가요?
1
380
2
안녕하세요. 초기 셋팅시 질문있습니다.
1
296
2
안녕하세요! Vuex, actions 질문이 있습니다.
1
305
2





