I have the below Vue component:
<template>
<v-snackbar bottom :color="color" v-model="snackbar">
{{ msg }}
<v-btn flat @click.native="close()">Close</v-btn>
</v-snackbar>
</template>
<script lang="ts">
import Vue from 'vue';
import VueEvent from '../../VueEvent';
export default Vue.extend({
data(): object {
return {
snackbar: false,
msg: '',
color: '',
};
},
created() {
VueEvent.listen('snackbar', (data) => {
this.snackbar = true;
this.msg = data.msg;
this.color = data.color;
});
this.malert();
},
methods: {
close(): void {
this.snackbar = false;
}
}
});
</script>
<style scoped>
</style>
When Typescript compiles I get the following error:
Property 'snackbar' does not exist on type 'CombinedVueInstance<Vue, object, { close(): void; }, {}, Readonly<Record<never, any>>>'.
28 | methods: {
29 | close(): void {
> 30 | this.snackbar = false;
| ^
31 | }
32 | }
33 | });
Does anyone know how I can solve this problem, or explain why its happening?
close(): voidas an arrow function?(this as any).snackbarbut it should work. I have looked at so many examples where this is how its done. I am also using the shim as stated in docs