TS class components

This commit is contained in:
Jörn-Michael Miehe 2022-09-09 23:14:03 +00:00
parent d5171ee531
commit 18bb455ec9
2 changed files with 16 additions and 23 deletions

View file

@ -3,30 +3,24 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import Vue from "vue"; import { Component, Prop, Vue } from "vue-property-decorator";
import moment from "moment"; import moment from "moment";
export default Vue.extend({ @Component
name: "ClockDisplay", export default class ClockDisplay extends Vue {
private clock = "";
data: () => ({ @Prop()
clock: "", format!: string;
}),
props: { private update(): void {
format: String,
},
methods: {
update(): void {
this.clock = moment().format(this.format); this.clock = moment().format(this.format);
}, }
},
created(): void { private created(): void {
setInterval(this.update, 1000); setInterval(this.update, 1000);
}, }
}); }
</script> </script>
<style> <style>

View file

@ -10,16 +10,15 @@
</template> </template>
<script> <script>
import Vue from "vue"; import { Component, Vue } from "vue-property-decorator";
import ClockDisplay from "./ClockDisplay.vue"; import ClockDisplay from "./ClockDisplay.vue";
export default Vue.extend({ @Component({
name: "TitleBar",
components: { components: {
ClockDisplay, ClockDisplay,
}, },
}); })
export default class TitleBar extends Vue {}
</script> </script>
<style> <style>