1

I have a simple vue component where i defined a boolean constant in data with start value false. I now want to create a method to change it to true and bind certain stuff conditionally to that in the template when it changes. But somehow i get the error "property value does not exist on type...". when i move computed out of data i get "Property 'computed' has no initializer"

export default class Something extends Vue {
  data() {
    return {
      value: false,
      computed: {
        valueTransform() {
          this.value = true
          alert(this.value)
        },
      },
    }
  }
}
1
  • You shouldn't update other data inside computed property Commented Oct 6, 2022 at 14:17

1 Answer 1

1

This syntax is not valid in class components, you should have something like :

export default class Something extends Vue {
 
    //data
      value = false,
     
    //computed 
       get valueTransform(){
        return this.value
      }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.