Home >Web Front-end >JS Tutorial >How to turn off the caching function of Vue computed properties? What are the specific steps?

How to turn off the caching function of Vue computed properties? What are the specific steps?

亚连
亚连Original
2018-06-01 16:50:151952browse

Below I will share with you an article on how to turn off the cache function that comes with Vue's calculated properties. It has a good reference value and I hope it will be helpful to everyone.

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
      }
    }
    }
  });

We need to set cache to false, thus clearing the cache , each time our time is the current time.

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Detailed explanation of password encryption processing operations in nodejs

Implementation method of handwritten Node static resource server

detailed explanation of nodejs connection to mysql database and basic knowledge points

The above is the detailed content of How to turn off the caching function of Vue computed properties? What are the specific steps?. 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