Mohammed Yousuff
Mohammed Yousuff

Reputation: 326

Variable is defined but never used (no-unused-vars)

Sorry for the poor English :) I have used the event Emit and on method to transfer the variable details from one module to another there is this above issue. My code below

In App.vue file

<v-btn class="ma-2" @click="closeModal()" tile large color="teal" icon>
              <v-icon>mdi-menu</v-icon>
            </v-btn>

methods: {
    closeModal() {
      this.mini = !this.mini;
      Event.$emit("i-got-clicked", this.mini);
    }
  }

In left anvigation file

<v-content :v-show="mini">

mounted() {
    Event.$on("i-got-clicked", mini => {
    //This mini is showing as defined but never used
      this.mini = !this.mini;
    });
  }

Apprecite any Answers thanks in advance

Upvotes: 2

Views: 17692

Answers (2)

ssc-hrep3
ssc-hrep3

Reputation: 16079

:v-show is equivalent to v-bind:v-show and that is not what you wanted to do. It would bind a variable with the name v-show to that element. Use v-show without the unnecessary colon in front of it. Otherwise it is not understood by Vue.

Read more about the :-shorthand for v-bind here.

Upvotes: 1

skirtle
skirtle

Reputation: 29092

The problem is the first line here:

Event.$on("i-got-clicked", mini => {

This introduces a variable called mini and it is not used in the code that follows. mini is not the same thing as this.mini.

Assuming you don't need it you can write this instead:

Event.$on("i-got-clicked", () => {

However, you may want to change the line that follows instead:

Event.$on("i-got-clicked", mini => {
  this.mini = mini;

Upvotes: 1

Related Questions