Skip to content
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

[2.5.7] Object destructuring within v-for gives "invalid v-for alias" error #7096

Closed
sqal opened this issue Nov 21, 2017 · 5 comments
Closed
Assignees

Comments

@sqal
Copy link
Contributor

sqal commented Nov 21, 2017

Version

2.5.7

Reproduction link

https://jsfiddle.net/j9ahLed9/

Steps to reproduce

Check console logs

What is expected?

I expect Vue to compile the above template without error

What is actually happening?

I get an error:

- invalid v-for alias "{ id, label }" in expression: v-for="{ id, label } in items"

`

@mirari
Copy link

mirari commented Nov 24, 2017

v-for="({name, value}) of list"
still get an error in 2.5.8

- invalid v-for alias "{name" in expression: v-for="({name, value}) of list"
- invalid v-for iterator "value}" in expression: v-for="({name, value}) of list"

@sqal
Copy link
Contributor Author

sqal commented Nov 24, 2017

Correct:

v-for="({name, value}) of list" throws the error -> https://jsfiddle.net/fok69xvz/

but works with index parameter -> https://jsfiddle.net/fok69xvz/1/

@mirari
Copy link

mirari commented Nov 24, 2017

@sqal
Sometimes I just want to add or remove index easily.
v-for="({name, value}) of list" works fine before 2.5.6
2.4.3
https://jsfiddle.net/fok69xvz/2/
2.5.6
https://jsfiddle.net/fok69xvz/3/

@yyx990803
Copy link
Member

yyx990803 commented Nov 24, 2017

@mirari fixed in aa82625

@yyx990803 yyx990803 reopened this Nov 24, 2017
@sqal
Copy link
Contributor Author

sqal commented Nov 27, 2017

@yyx990803 There's still one case when it still does not work correctly -> array destructuring. Example using latest Vue 2.5.9 https://jsfiddle.net/bc1r9295/. Actually i found it reading vuejs/vue-loader#1062 And in 2.5.6 first two examples works fine, but the third one with index argument gives SyntaxError: Unexpected token error

lovelope pushed a commit to lovelope/vue that referenced this issue Feb 1, 2018
f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
aJean pushed a commit to aJean/vue that referenced this issue Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants