Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 944 Bytes

this-in-template.md

File metadata and controls

65 lines (46 loc) · 944 Bytes

enforce usage of this in template (vue/this-in-template)

  • ⚙️ This rule is included in "plugin:vue/recommended".

📖 Rule Details

👎 Examples of incorrect code for this rule:

<a :href="this.url">
  {{ this.text }}
</a>

👍 Examples of correct code for this rule:

<a :href="url">
  {{ text }}
</a>

🔧 Options

Default is set to never.

'vue/this-in-template': [2, 'always'|'never']

"always" - Always use this while accessing properties from Vue

👎 Examples of incorrect code:

<a :href="url">
  {{ text }}
</a>

👍 Examples of correct code`:

<a :href="this.url">
  {{ this.text }}
</a>

"never" - Never use this keyword in expressions

👎 Examples of incorrect code:

<a :href="this.url">
  {{ this.text }}
</a>

👍 Examples of correct code:

<a :href="url">
  {{ text }}
</a>