I am trying to use typescript along with Vue (I am new at it) in my vue but having issue as it seems like it is scope problem. I might be wrong. I took small example from VueJS and made it like following
Cannot read property 'message' of null"
<template>
<button @click="onClick">Click!</button>
</template>
<script lang="ts">
import Vue from 'vue'
import Component from 'vue-class-component'
export default class MyComponent extends Vue {
// Initial data can be declared as instance properties
message: string = 'Hello!'
// Component methods can be declared as instance methods
onClick (): void {
window.alert(this.message)
}
}
</script>
What am I missing?