I want to wrap a class object in reactive, so i can trigger my methods which works on the attributes and the latest values of the attributes are displayed.
For example on this Example Code:
<script setup lang="ts">
import { reactive, nextTick } from 'vue'
class Test {
public num: number;
public constructor() {
this.num = 3;
}
public increment = () => {
this.num++;
}
}
const test = reactive(new Test());
</script>
<template>
<h1>{{ test.num }}</h1>
<button @click="test.increment">Add 1</button>
</template>
the value of the header should show the value 4 after once pressed the button. But when pressing the button the value does not change?
Is there any cleaner solution instead of marking all class attributes as ref? I hoped I can use reactive to get this job done. A code example is at vue playground
Thanks for your help.