«

methods和computed之前的区别

时间:2023-6-15 11:13     作者:小诸葛     分类: Vue     正在检查是否收录...


1.methods和computed相同点都是可以进行一个计算


2.methods和computed不同点,computed比methods的运行效率高,methods每次被调用都会执行,但是computed只会执行一次,(只有当引用的值发送改变的时候才会执行,有缓存功能,提高了性能)


3.methods和computed用法不同,methods调用的时候需要加(),computed不需要,例如:


<p>总价{{a()}}</p> //methods
<p>总价{{a}}</p> //computed

vue methods computed

推荐阅读:


扫描二维码,在手机上阅读