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
  • 10,013
  • 17
  • 56
  • 102

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
  • 10,013
  • 17
  • 56
  • 102
Adam Jenkins
  • 51,445
  • 11
  • 72
  • 100