我正在尝试使用 vue-class-component 和 typescript(在此处找到https://github.com/vuejs/vue-class-component)创建一个 vue 组件。据我了解,数据是在类中定义的,如下所示 - 但我收到错误:
"[Vue warn]: Property or method "test" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property."
这是我的实际代码的精简版,但它仍然不起作用:
<template>
<div id="vue-test">
<input v-model="test"/>
{{test}}
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
@Component({
})
export default class AppearanceDialogVue extends Vue {
public test: string = '100';
}
</script>
编辑:似乎将“测试”声明更改为
public test: string;
工作过