language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

v-bind shorthand syntax is not supported for :class

Open GideonMegaport opened this issue 3 months ago • 6 comments

When using an attribute named class the v-bind shorthand produces the 'v-bind' directives require an attribute value. error.

To reproduce:

<script lang="ts" setup>
defineProps<{
  color: string
  class: string
}>()
</script>

<template>
  <div
    :class
    :color></div>
</template>

In the above code, the color attribute is accepted but the class attribute isn't.

GideonMegaport avatar Mar 13 '24 02:03 GideonMegaport

Do you have a reproduction repo? I can't reproduce this on my machine.

so1ve avatar Mar 13 '24 04:03 so1ve

Here is a reproduction repo: https://github.com/GideonMegaport/vbindTest

The relevant code is in src/components/TestComponent.vue

I created a blank Vue 3 project with the following settings: ✔ Add TypeScript? … Yes ✔ Add JSX Support? … No ✔ Add Vue Router for Single Page Application development? … No ✔ Add Pinia for state management? … No ✔ Add Vitest for Unit Testing? … No ✔ Add an End-to-End Testing Solution? › No ✔ Add ESLint for code quality? … Yes ✔ Add Prettier for code formatting? … Yes ✔ Add Vue DevTools extension for debugging? (experimental) … No

In VSCode I disabled all extensions except Vue - Official and ESLint

The error shows up no matter what order I put the attributes in.

GideonMegaport avatar Mar 14 '24 01:03 GideonMegaport

image

It works?

so1ve avatar Apr 08 '24 03:04 so1ve

Still doesn't work for me. Screenshot 2024-04-08 at 2 32 34 PM

GideonMegaport avatar Apr 08 '24 04:04 GideonMegaport

Pretty weird, what's your vue and volar's version?

so1ve avatar Apr 08 '24 04:04 so1ve

I'm using "Vue - Official" v2.0.10 and Vue 3.4.21([email protected])

I just downloaded the repository zip and did a pnpm i

GideonMegaport avatar Apr 10 '24 00:04 GideonMegaport