IT/실수하지말자
[Vue.js] 최신 Typescript를 사용할 경우, 발생하는 에러
Terriermon
2022. 1. 25. 23:29
Property '변수명' has no initializer and is not definitely assigned in the constructor.
Vue.js를 인프런 강의를 보면서 따라한 후, 실행하면서 아래 코드에서 위 에러가 발생했다.
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
@Component
export default class NameButton extends Vue{
@Prop() name: string;
}
</script>
해결 방법
Property '...' has no initializer and is not definitely assigned in the constructor
in my Angular app i have a component: import { MakeService } from './../../services/make.service'; import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-vehicle-form',
stackoverflow.com
최근 typescript는 엄격한 문법을 따르기 때문에, 초기화가 필요하다.
@Prop() name: string = "";
초기화를 해주면 된다.
반응형