0

When I write the code like this, it works:

<script>
export default {
    props: ["notes"],
    computed: {
      hasNotes() { return this.notes && this.notes.some(x => x); }
    }
};
</script>

but when I write it like this, it fails:

<script>
export default {
    props: ["notes"],
    computed: {
      hasNotes : ()=> this.notes && this.notes.some(x => x)
    }
};
</script>

... and I don't understand why. What am I doing wrong here?

Scott Baker
  • 9,574
  • 16
  • 52
  • 98

1 Answers1

0

I'm certain this is a dupe of something, but an arrow function uses lexically scoped this so this doesn't mean what you think it means inside the arrow function.

Scott Baker
  • 9,574
  • 16
  • 52
  • 98
Adam
  • 46,658
  • 11
  • 63
  • 84