I am in the process of setting up a new VueJs application based on an existing Typescript-class structure with typescript model-classes. How should I integrate my models so that two-way-binding in vuejs can function properly and recognize updates on the model?
I attempted to import the model class "person" and declared it as a class variable.
<template>
<form>
<input type="text" v-model="person.name" />
{{person.name}}
</form>
</template>
<script lang="ts">
import {Person} from '@/models/person';
import Vue from 'vue';
import {Component} from 'vue-property-decorator';
@Component({})
export default class Home extends Vue{
public person! : Person;
created(){
this.person = new Person();
}
}
</script>
--- Following person.ts:
export class Person{
public name : string;
public birthday: Date;
}
My hope is that by changing the input field for "name", the '{{name}}' will also change... Currently, only calling this.$forceUpdate(); seems to do the trick :(