question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

init data by access props is undefinded

See original GitHub issue

code 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:open
  • Created a year ago
  • Reactions:4
  • Comments:7

github_iconTop GitHub Comments

6reactions
farazshujacommented, Aug 2, 2022

Added in tsconfig.json, now its working fine for me "useDefineForClassFields": false,

tested on typescript v. 4.7.4

1reaction
kagaricyancommented, Jul 22, 2022

I decide rewrite all class component using composition api

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found