Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

vue settimeout in computed

// It won't work because
//inputDisabled() itself is not the one returning true.

computed; {
    inputDisabled() {
        setTimeout( () => {
            return true;
        }, 1000);
    }
}

// try this instead.

data(){
  return {
    inputDisabled: true // initial value
  }
},
mounted(){ // after the component instance has been mounted,
  setTimeout(
    _ => this.inputDisabled = false, // enable the input
    1000 // after 1 second
  )
}
Source by www.reddit.com #
 
PREVIOUS NEXT
Tagged: #vue #settimeout #computed
ADD COMMENT
Topic
Name
7+2 =