[Vuejs]-How do I loop through a proxy array in Vue?

0👍

Since Vue 3 there are now two APIs, Options API and Composition API. You’re using the older Options API. If you’re not familiar with Vue, it’s prudent you learn the difference between the APIs so you can identify online resources that are relevant to your chosen API. The Vue docs themselves show Composition API by default but has a toggle in the top-left to change the documentation to Options API.

Regarding your actual question, with Options API you don’t have to do anything special. Treat this.exampleArray as a normal JS array. Vue will handle the wrapping/unwrapping of the Proxy for you.

this.exampleArray.forEach(i => console.log(i))

toRaw() is specifically for Composition API. See how the documentation for toRaw is under the "Composition API" section in the sidebar. Because you’ve chosen to use Options API you wouldn’t ever use it.

Leave a comment