vuejs / vue-class-component

ES / TypeScript decorator for class-style Vue components.
MIT License
5.81k stars 429 forks source link

Vue3: devtools does not show non-default initialized component properties #533

Open nicolidin opened 3 years ago

nicolidin commented 3 years ago

Hello,

If a component has two properties, where one is default initialized and the other is initialized in the created() hook:

<template>
  <div>TESTTT</div>
</template>

<script lang="ts">
import { Vue, Options, Prop } from "vue-property-decorator";

@Options({
  name: "Test",
  components: {},
})
export default class Test extends Vue {
  first = 1;
  second!: number;

  created() {
    this.second = 1;
  }
}
</script>

The vue-devtools is not able to detect the properties that are not directly default initialized... As we can see on the screen below: image Only the first property appear in the setup part but not second.

This is an important problem, a lot of our properties can't be directly initialized, and adding a default value like null is not often desirable. Hope someone can solve this issue @posva @ktsn

QingquanQiu commented 3 years ago

Maybe this can be helpful https://class-component.vuejs.org/guide/class-component.html#data