Vue project city selection page-list performance optimization (8-7)

List performance optimization

If you slide your finger on it, our value will change, but our performance is very low. Because we will recalculate every time we slide.
Insert picture description here

Add a life cycle hook updated
Insert picture description here
because our value is set to empty at the beginning, so every time we get json, we will refresh it again. Then if we use updated, we can solve the low performance of reloading every time we refresh.

Throttling
Insert picture description here
Every time we slide, the frequency is very high, so we have to do a throttle.
Insert picture description here
In fact, it is adding a timer.

Guess you like

Origin blog.csdn.net/weixin_45647118/article/details/114275627