Reputation: 322
I'm using Vue.js and TypeScript and I've done a DataPicker. It's working but I can't build due to errors in TypeScript.
Here is my DatePicker typescript file :
import Vue from "vue"
export default Vue.extend({
data: () => ({
message1: "",
date: null,
menu: false
}),
watch: {
menu(val) {
val && setTimeout(() => (this.$refs.picker.activePicker = 'YEAR'))
}
},
methods: {
save(date){
this.$refs.menu.save(date)
},
}
})
I have errors on the date var, save method and ActivePicker.
Do someone have any idea how to "import" them in my DatePicker.ts. By the way, I'm using splitted files like this :
DatePicker.vue
DatePicker.html
DatePicker.ts
Thank you !
Antoine
Upvotes: 1
Views: 129
Reputation: 1730
I think the problem is you are using an arrow function in the wrong place.
if you call setTimeout with an arrow function, you don't have this bound as you want it.
simply try putting a function () {...}
instead of () => {...}
or use the this.$nextTick(() => {....})
Upvotes: 1