Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (51 sloc) 1.31 KB
pageClass sidebarDepth title description
rule-details
0
vue/this-in-template
disallow usage of `this` in template

vue/this-in-template

disallow usage of this in template

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

📖 Rule Details

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>

🔧 Options

{
  "vue/this-in-template": ["error", "always" | "never"]
}
  • "always" ... Always use this while accessing properties from Vue.
  • "never" (default) ... Never use this keyword in expressions.

"always"

<template>
  <!-- ✓ GOOD -->
  <a :href="this.url">
    {{ this.text }}
  </a>
  
  <!-- ✗ BAD -->
  <a :href="url">
    {{ text }}
  </a>
</template>

🔍 Implementation

You can’t perform that action at this time.