T
T
tenaro2021-12-07 14:33:26
JavaScript
tenaro, 2021-12-07 14:33:26

Vue. How to copy an array and disable reactivity?

there is a reactive array, how to make a local copy for manipulations that will not affect the original data?

items = [...] // реактивный массив
localItems = items
localItems.push(data) // данные добавляются в items, надо это предотвратить

I know a way with JSON.parse(JSON.stringify(items)) - but it doesn't look very good, how can I do it better?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Kuzmenko, 2021-12-07
@tenaro

_.cloneDeep(value)
localItems = _.cloneDeep(items)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question