Home  >  Article  >  Web Front-end  >  How to disable the caching function that comes with vue computed properties

How to disable the caching function that comes with vue computed properties

php中世界最好的语言
php中世界最好的语言Original
2018-03-27 17:26:011713browse

This time I will show you how to disable vue calculationpropertybuilt-incachefunction, disable vue calculation property’s built-in cache functionnotesare Which ones, the following are practical cases, let’s take a look.

Everyone who uses Vue will know the calculated properties of vue. This is explained in this way. When certain dependency values ​​change, its own value will also change, and the DOM related to it will also change. Usually, there are two methods in this calculated attribute: get and set can be used.

Here I will only analyze how to turn off the cache of calculated attributes and obtain the latest data, as shown in the following example:

## HTML code

<p id="mess">
    <p>{{exapm}}</p>
  </p>

JS code:

 var vue2 = new Vue({
    el:"#mess",
    data:{
      sendmess:" i dhsjknkjvnkrenvr"
    },
  computed:{
    exapm:{
      cache:false,
      get:function(){
        return Date.now()+this.sendmess
      }
    }
    }
  });
I believe you have mastered the method after reading the case in this article, more Please pay attention to other related articles on the php Chinese website!

Recommended reading:

How jQuery implements left and right sliding toggle

##Use index to add the first item in Vuejs Class method

The above is the detailed content of How to disable the caching function that comes with vue computed properties. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn