init data by access props is undefinded
See original GitHub issuecode example:
<template>
<span>{{ test }}-{{ local }}</span>
</template>
<script>
import { Component, Prop, Vue } from 'vue-property-decorator';
@Component
export default class HelloWorld extends Vue {
@Prop({default: ()=>({aaa: 456})}) msg;
local = JSON.parse(JSON.stringify(this.msg));
get test() {
return this.msg.aaa;
}
}
</script>
this code is works in lower version. recent days,i want to upgrade my dependencies, but get problems with this code.
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:7
Top Results From Across the Web
Why I am getting `this.props.data is undefined` error?
First, way too much code. Try to be as concise as possible. Your issue is that this.state.data in CommentBox is undefined / null...
Read more >Composition API: setup() - Vue.js
The setup() hook serves as the entry point for Composition API usage in components in the following cases: Using Composition API without a...
Read more >How to Read React Errors (fix 'Cannot read property of ...
That's often because the array is a piece of undefined state or an undefined prop. Make sure to initialize the state properly.
Read more >How passing props to component works in React
Master how to pass props (properties) to components in React with this useful beginner's guide, including demo code.
Read more >Resolve injected properties after the props initialization #9471
smellyshovel commented on Feb 10, 2019. The change was made to allow access to the injected values when data() runs - kind ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Added in tsconfig.json, now its working fine for me
"useDefineForClassFields": false,
tested on typescript v. 4.7.4
I decide rewrite all class component using composition api