vue optimization Object.freeze

Some data in the Vue project are only used for display, such as comment lists, etc., and will not be modified. You will use Object.freeze to process it. When vue performs responsive processing, you will see that the data becomes a responsive object, which is also one of the optimization methods. Especially when there is a large amount of article list data, the effect is more obvious.

let d =[1,2,3]
Object.freeze(d);
d[1]= 3;
console.log(d)//[1,2,3] 修改无效,是不会变的。

Guess you like

Origin blog.csdn.net/qq_42931285/article/details/134228874