vue computed caching issue - Stack Overflow
三叔
三叔 2017-06-12 09:31:36
0
2
840

I read the official document says:

The difference between

computed and methods is that computed will be cached based on their dependencies. If the data cannot be changed, computed It will not be re-executed when refreshing, but methods will be executed every time.

But the examples I wrote are not like this (the examples I wrote are official examples).

html:

<p id="app">
    <p>{{methodsNow()}}</p>
    <p>{{computedNow}}</p>
</p>

javascript:

new Vue({
    el:'#app',
    data:{

    },
    methods:{
        methodsNow:function(){
            return new Date().toLocaleString();
        }
    },
    computed:{
        computedNow:function(){
            return new Date().toLocaleString();
        }
    }
});

Let’s discuss, did I write something wrong somewhere?

三叔
三叔

reply all(2)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!