Home > Article > Web Front-end > How to turn off the caching function of Vue calculated properties
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 the cache to false, so that the cache is cleared and our time is the current time every time.
Related recommendations:
Detailed explanation of bugs encountered when v-for handles arrays when vue calculates attributes
The above is the detailed content of How to turn off the caching function of Vue calculated properties. For more information, please follow other related articles on the PHP Chinese website!