-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Deprecate v-repeat
in favor of v-for
#1200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Nice ! How can we install this version via npm ? |
@sdebacker This is a proposal for 1.0. |
Yes but these proposed changes are already pushed to 1.0.0-alpha branch. |
@sdebacker You can install a branch as |
Thanks but it returns no matches found: yyx990803/vue#1.0.0-alpha |
@sdebacker what version of npm are you using? |
I just upgrade npm to 2.12.1 via homebrew, perhaps I need 2.14 ? |
weird... I just tried it and it works... maybe a typo? ;) |
+1 great proposal |
+1 |
5 similar comments
+1 |
+1 |
👍 |
👍 |
+1 |
So, this: |
Implemented in alpha branch. |
@yyx990803 I switched from zsh to bash and I can now run |
So if I am interpreting this correctly, deprecation of v-repeat in lieu of the v-for will create true partials as opposed to vms. Within the standard use case, will we experience any loss of functionality when passing this object back to event handlers? |
@mattymil I've yet to see a use case where the anonymous child vm is necessary. In most cases you pass the |
ok interesting. Thanks
|
+1 |
So by the doc in rc.vuejs.org, this syntax is not support in 1.0.0? <li v-for="items"></li> |
@furybean it's not supported, you have to use |
@simplesmiler Thanks. |
A little late to the party but... Since |
+1 |
I am working on a new version of
v-repeat
, which is significantly more performant than the current version, but introduces a few breaking differences in terms of scoping. In order to keep backwards compatibility in the 1.0 migration, this new version will be introduced asv-for
so that the originalv-repeat
can be left intact.Current status: all tests passed. You can test
v-for
in the current 1.0.0-alpha branch.Difference between
v-for
andv-repeat
Required alias
Alias is required when using
v-for
, and theitem in items
syntax is preferred. It reads more naturally:This also means the
$value
meta property will no longer be used.$index
and$key
are still available. You can also still refer to the parent scope index in nested loops as$parent.$index
.No more anonymous child VMs
Previously,
v-repeat
creates an actual child VM instance withinherit: true
for every repeated block. This is no longer the case withv-for
: each repeated block inv-for
is now a real partially compiled fragment, with a lightweight intermediate "scope". This greatly reduces the overhead and as a result you should see significant performance improvement for both initial rendering (up to 100% for non-component loops) and re-rendering withtrack-by
(up to 50%, as tested in dbmonster).This also means:
<template>
repeat no longer creates the overhead of a child instance.v-ref
would not work onv-for
if the repeated block is not a component, because there are no longer anonymous child instances created in that case.Component Scoping
Now this is the part that is the most different. Previously when you use a component with
v-repeat
, you get somewhat weird scoping:In the above example,
item
and$index
are automatically available inside the component, but not in the parent template. If you do want to use$index
in the parent template, you have to create a<template>
to wrap the repeat. In addition, this requires the component implementation to be aware that it isv-repeat
specific, because the external data is not received via the standardprops
interface.With
v-for
, you get the expected scoping:And you need to explicitly pass external data into the component as
props
. This makes your component implementation no longerv-repeat
specific and less magical.The text was updated successfully, but these errors were encountered: