Imagine you have an input field in Vue.JS with a v-model
that binds to a String data property, and a long list of random numbers that are completely unrelated to the first String.
data: {
input: "",
randoms: []
}
<input type="text" v-model="input">
<p v-for="random in randoms" v-text="random"></p>
Combining both in the same Vue instance results in a significant slowdown when typing in the input field. It seems like Vue is reevaluating the DOM for each list entry after every input event, although they are not related at all.
https://jsfiddle.net/5jf3fmb8/2/
However, moving the v-for
to a child component where randoms
is bound to a prop eliminates this slowdown.
https://jsfiddle.net/j601cja8/1/
Is there a way to achieve the performance of the second example without using a child component?