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 1 year 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

Hey there, as there have been many fixes in the last 2.x versions: If you're still encountering issues, please provide a minimal reproduction. Otherwise kindly close this one, thanks!

davidmatter avatar Aug 06 '24 07:08 davidmatter

I just tried it again with v2.0.28 and still have the same error.

The minimal reproduction is already provided above.

I also updated all the dependencies in my project to the latest and that made no difference.

I also downloaded the source from the repository above and set it up on a completely separate computer, and was able to reproduce the same problem.

GideonMegaport avatar Aug 06 '24 07:08 GideonMegaport

Right, this is an eslint issue. You might want to transfer this issue to https://github.com/vuejs/eslint-plugin-vue image

davidmatter avatar Aug 06 '24 07:08 davidmatter