JS.VUE.NO.UNUSED.REFS

Disallow unused refs

Rule Details

This rule is aimed at eliminating unused refs. This rule reports refs that are defined using the ref attribute in <template> but are not used via $refs.

This rule cannot be checked for use in other components (e.g. mixins, Access via $refs.x.$refs).

{'vue/no-unused-refs': ['error']}

Copy
<template>
  <!-- GOOD -->
  <input ref="foo" />

  <!-- BAD (`bar` is not used) -->
  <input ref="bar" />
</template>
<script>
export default {
  mounted() {
    this.$refs.foo.value = 'foo'
  }
}
</script>

Options

Nothing.

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/