pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
vue/this-in-template |
disallow usage of `this` in template |
v3.13.0 |
disallow usage of
this
in template
- ⚙️ This rule is included in all of
"plugin:vue/recommended"
,*.configs["flat/recommended"]
,"plugin:vue/vue2-recommended"
and*.configs["flat/vue2-recommended"]
. - 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
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>
This rule was introduced in eslint-plugin-vue v3.13.0