You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<template>
<divclass="hello">
<h1>{{ msg }}</h1>
</div>
</template>
<script lang="ts">
import { Options, Vue } from"vue-class-component";classProps { msg!:string;}exportdefaultclassWtfextendsVue.props(Props) { mounted() {console.log(this.msg); }}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
when running yarn serve the prop msg printed in mounted is undefined and we have the following warning
[Vue warn]: Property "msg" was accessed during render but is not defined on instance.
at <Wtf msg="Welcome to Your Vue.js + TypeScript App" >
at <App>
undefined
notice that even we replace
classProps{msg!: string;}
by
classProps{msg=" ";}
then its working fine
I have a vue3 vue class component typescript project that use Ionic and it has not such an issue despite using the same vue-class-component beta release.
You need to specify "useDefineForClassFields": true for TypeScript compiler option to let Vue Class Component aware of the properties without initializer
Steps to reproduce this critical bug:
so we have the two following basic components:
parent Component:
Child component
when running yarn serve the prop msg printed in mounted is undefined and we have the following warning
notice that even we replace
by
then its working fine
I have a vue3 vue class component typescript project that use Ionic and it has not such an issue despite using the same vue-class-component beta release.
I've made the following reproducer
https://github.com/LifeIsStrange/vue-class-component-with-vue3-props-bug-reproducer
@ktsn
The text was updated successfully, but these errors were encountered: