current position:Home>[Vue] performance optimization 1 - free

[Vue] performance optimization 1 - free

2021-08-26 05:32:07 DiracKeeko

Need to show a long list , Just show , No data changes involved , How to optimize performance at this time ?
vue During initialization, it will traverse data Data in , adopt Object.defineProperty() Set... For each data setter and getter Method , This process is very performance intensive .
Since there is no need to change , Then you don't need the data to become responsive , That is, there is no need to let Vue To traverse .

There are two methods available :

1、Object.freeze Freeze objects

template part
image.png
data part
image.png
methods part
image.png

2、 Do not place data in data in , It is placed with data/methods/computed At the same level , Then template of use $options To get data .

template part
image.png
data and Method section
image.png

Synchronize updates to your own language bird
https://www.yuque.com/diracke...

copyright notice
author[DiracKeeko],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2021/08/20210826053205264l.html

Random recommended