-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed
Labels
Description
Version
2.4.2
Reproduction link
https://github.com/Justineo/vue-esnext-in-template
Steps to reproduce
vue init webpack esnext-in-template
src/components/Hello.vue
:
<template>
<div :class="{ a: true, ...b }"></div>
</template>
<script>
export default {
data () {
return { b: true }
}
}
</script>
(babel-preset-stage-2
is already enabled after initializing with vue-cli
.)
What is expected?
The class
value should be a b
.
What is actually happening?
Error compiling template:
- invalid expression: :class="{ a: true, ...b }"
vue-template-compiler
seems to be validating the expression before it goes through Babel with trying to evaluate new Function(exp)
. This makes ES features that can be used in templates limited to those Node supports and causes confusion: I can translate spread operators for arrays both in templates and elsewhere but I can translate spread operators for objects anywhere except in templates. I think this might not be intentional so I mark this as a bug.
qbaty, chestnutchen, 599316527, wkaifang, FranckFreiburger and 16 more