Skip to content

Array destructuring in v-for #1062

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

Closed
dimensi opened this issue Nov 16, 2017 · 3 comments
Closed

Array destructuring in v-for #1062

dimensi opened this issue Nov 16, 2017 · 3 comments

Comments

@dimensi
Copy link

dimensi commented Nov 16, 2017

Version

13.5.0

Reproduction link

https://codesandbox.io/s/l72vorr44m

Steps to reproduce

  1. set directive v-for="([rank, text, percent], index) in refTable"
  2. get error

What is expected?

Expect work

What is actually happening?

Error


I have some issue like here #630

Module build failed: SyntaxError: Unexpected token (1:864)
    at Parser.pp$4.raise (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:2610:13)
    at Parser.pp.unexpected (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:637:8)
    at Parser.pp$2.parseBindingAtom (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1602:10)
    at Parser.pp$2.parseMaybeDefault (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1640:23)
    at Parser.pp$2.parseBindingList (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1625:25)
    at Parser.pp$1.parseFunctionParams (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1189:22)
    at Parser.pp$1.parseFunction (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1176:8)
    at Parser.pp$3.parseExprAtom (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:2082:17)
    at Parser.parseExprAtom (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:4372:24)
    at Parser.pp$3.parseExprSubscripts (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1955:19)
    at Parser.pp$3.parseMaybeUnary (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1932:17)
    at Parser.pp$3.parseExprOps (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1874:19)
    at Parser.pp$3.parseMaybeConditional (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1857:19)
    at Parser.pp$3.parseMaybeAssign (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1832:19)
    at Parser.pp$3.parseExprList (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:2528:20)
    at Parser.pp$3.parseSubscripts (/home/dimensi/projects/sdm-front-spa/node_modules/vue-template-es2015-compiler/buble.js:1983:29)
 @ ./src/views/pages/Stocks.vue 10:0-366
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi ./build/dev-client ./src/main.js
@Jinjiang
Copy link
Member

Jinjiang commented Nov 16, 2017

Just remove the bracket: v-for="[foo, bar], index in arr" is fine.

I found that the generated code will become something like:
_l((${V_FOR_ARRAY}), function (${V_FOR_ARGUMENTS}) { ... }.

So _l((refTable), function ([foo, bar], index) { ... }) works,
but _l((refTable), function (([foo, bar], index)) { ... }) fails with a syntax error.

Thanks.

@Jinjiang
Copy link
Member

@defcc Is it possible to automatically remove the brackets through vue-template-compiler? Maybe you can help this :-)
Thanks.

@dimensi
Copy link
Author

dimensi commented Nov 12, 2021

@yyx990803 @Jinjiang Maybe close this?

@dimensi dimensi closed this as completed May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants