Vue: [2.5.7] Object destructuring within v-for gives "invalid v-for alias" error

Created on 21 Nov 2017  路  5Comments  路  Source: vuejs/vue

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"

`

regression

Most helpful comment

@mirari fixed in aa8262540ac0115d56b53863302b9f8e69f8a03d

All 5 comments

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"

Correct:

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

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

@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/

@mirari fixed in aa8262540ac0115d56b53863302b9f8e69f8a03d

@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 https://github.com/vuejs/vue-loader/issues/1062 And in 2.5.6 first two examples works fine, but the third one with index argument gives SyntaxError: Unexpected token error

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wenLiangcan picture wenLiangcan  路  39Comments

ShuvoHabib picture ShuvoHabib  路  40Comments

karevn picture karevn  路  36Comments

asiFarran picture asiFarran  路  34Comments

smolinari picture smolinari  路  116Comments