类型错误: 无法读取 null 的属性"$emit" ("THIS"为 NULL)



我正在将我的项目从JS转换为TS,我不知道为什么我不能调用"这个";在这里

<template>
<transition name="modal">
<div class="modal-mask">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-body">
<div class="text-right">
<label>
<span>
<v-icon name="times" scale="1.5" />
<button
@click="closeModal"
type="button"
class="btn btn-sm btn-outline-info btn-block"
style="display: none"
>
Cancel
</button>
</span>
</label>
</div>
<h4 class="text-center title-switch">
<span style="font-weigth: bold">{{ title }}</span
>リストに追加しますか?
</h4>
<div class="d-flex justify-content-center align-items-center mb-2">
<button @click="closeModal" class="btn btn-no mr-5">No</button>
<button @click="getDate" class="btn btn-yes">Yes</button>
</div>
</div>
</div>
</div>
</div>
</transition>
</template>
<script lang="ts">
import { Vue, Prop } from 'vue-property-decorator';
import { chatModule } from '@/store/modules/manage-chat';
export default class ModalConfirm extends Vue {
@Prop(String) readonly title!: string;
@Prop(Boolean) readonly check!: boolean;

closeModal(): void {
if (confirm('Close the window without saving?')) {
chatModule.actionChangeNgListState({
status: false,
});
this.$emit('close');
}
}
}
</script>

这是日志

app.js:sourcemap:161212 TypeError: Cannot read property '$emit' of null

在其他文件中,我仍然可以使用";这个";是方法,但在这种方法中我不能

[SOLVED]:我已经解决了我的问题。它的原因是我忘记添加这个装饰器@Component({})。所以当你发现这个问题时,请添加这个。

最新更新