How to set a component non-reactive data in Vue 2?

前端 未结 5 1069
别跟我提以往
别跟我提以往 2020-12-03 10:05

I have a categories array, which is loaded once (in created hook) and then it is static all the time. I render this array values in a component template.

<         


        
5条回答
  •  [愿得一人]
    2020-12-03 10:27

    If you want to keep it in data, the proper way is using Object.freeze(), as described in the documentation:

    The only exception to this being the use of Object.freeze(), which prevents existing properties from being changed, which also means the reactivity system can’t track changes.

提交回复
热议问题