Pattern: Use of this
in template
Issue: -
This rule aims at preventing usage of this
in Vue templates.
<template>
<!-- ✓ GOOD -->
<a :href="url">
{{ text }}
</a>
<!-- ✗ BAD -->
<a :href="this.url">
{{ this.text }}
</a>
</template>
{
"vue/this-in-template": ["error", "always" | "never"]
}
"always"
... Always usethis
while accessing properties from Vue."never"
(default) ... Never usethis
keyword in expressions.
<template>
<!-- ✓ GOOD -->
<a :href="this.url">
{{ this.text }}
</a>
<!-- ✗ BAD -->
<a :href="url">
{{ text }}
</a>
</template>