M
M
MarEeeeeee2020-10-01 10:44:45
JavaScript
MarEeeeeee, 2020-10-01 10:44:45

How to fix 'secondWindow' is assigned a value but never used no-unused-vars' error?

I export props firstWindow, secondWindow to this file, but there are some problems with secondWindow.

<template>
    <div class = "row__elements">
       <div @click="event =>clickOnRow(elem, whichScreen, firstWindow, secondWindow)" class = "row__element">
           <div class = "file-info"> </div>
           <div class = "file-info title"> {{elem.fileName}} </div>
           <div class = "file-info size"> {{elem.sizeOrType}} </div>
           <div class = "file-info date"> {{elem.dateOfChange}} </div>
           <div class = "file-info date"> {{whichScreen}} </div>
           <div class = "file-info date"> {{elem.dir}} </div>                  
        </div>   
    </div>
</template>


<script>
export default {
    props:{
        elem:{
            type:Object,
            default: () => ({}),
            required: true,             
        },
        whichScreen:{
            type:Boolean,
            default: false,
        },
        firstWindow:{
            type:Object,
            default: () => ({}),
        },
        secondWindow:{
            type:Object,
            default: () => ({}),
        },
    },
    
    data()
        { 
            return{
                delay: 500,
                clicks: 0,
                timer: null,
                helper:[],                
            } 
        },
    methods:{
        clickOnRow: function(elem, whichScreen, firstWindow, secondWindow){
          this.clicks++ 
          if(this.clicks === 1) {
            var self = this
            this.timer = setTimeout(function() {            
            console.log("одинарный");                 
              self.clicks = 0
            }, this.delay);
          } else{
             clearTimeout(this.timer);
             console.log("двойной");
             
             elem['whichScreen']  = whichScreen;    
             console.log(elem);
                  
             this.helper = fetch('/currentDir1',{
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',                    
                },
                body: JSON.stringify(elem)                
                })               
             if(whichScreen){
                 firstWindow = this.helper;
                 secondWindow = this.secondWindow;
             }else{
                 secondWindow = this.helper;
                 firstWindow = this.firstWindow;
             }            
             
             this.clicks = 0;                          
          }        	
        }
    }, 
}
</script>


I suspect that this may be due to the fact that I use this component twice and send different values ​​to it. See below

<template>
    <div class = "main-window">
        <ul>    
            <Directoire
             v-bind:directories="directories"
            />
            <span>{{firstDir}}</span>                              
            <Item           
            v-for="elem of firstWindow.table"
            v-bind:key="elem"
            v-bind:elem="elem"
            v-bind:whichScreen="whichScreen"
            v-bind:firstWindow="firstWindow"
            v-bind:secondWindow="secondWindow"
            />
        </ul>
        <ul> 
             <Directoire
              v-bind:directories="directories"
             />  
              <span>{{secondDir}}</span>            
             <Item
            v-for="elem of secondWindow.table"
            v-bind:key="elem"
            v-bind:elem="elem"
            v-bind:whichScreen="!whichScreen"
            v-bind:firstWindow="firstWindow"
            v-bind:secondWindow="secondWindow"
            />   
        </ul>      
        
    </div>
</template>

<script>
import Item from '@/components/itemVue.vue'
import Directoire from '@/components/DirectoriesVue.vue'


export default {
    props: ['firstWindow','secondWindow', 'directories', 'firstDir', 'secondDir', 'whichScreen'], 
    components:{
        Item,        
        Directoire
    }
}
</script>


Tell me how to fix this, I will be very grateful!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question