[Vuejs]-Vuejs Computed data detecting if model has been updated

0๐Ÿ‘

โœ…

I got this to work using a temp variable

data(){
   return: {
      text: "",
      temp: {
         text
      }
   }
}

computed(){
   filteredList(){
       var temporaryList,originalList,filteredList


       if ((this.text === $store.state.selectedText )||
           (this.text === this.temp.text ) ) {
                return temporaryList || originalList
           }

       // update
       this.temp.text = this.text

       return filteredList
   }
}

thought it would be a bad practice to update variables within a Computed method.

0๐Ÿ‘

Create a variable, changed. Watch selectedItem.text, and set changed to true. In a watcher on text, set changed to false.

Leave a comment