vue icon indicating copy to clipboard operation
vue copied to clipboard

Warn if colon shorthand is used on v-if/v-html/etc.

Open simonhermann opened this issue 4 years ago • 12 comments

What problem does this feature solve?

I just spent way too long debugging something really weird until I realized I accidentally wrote :v-if instead of v-if.

A warning when wrongly using shorthands like : on "native" vue attributes could prevent this bad experience easily.

What does the proposed API look like?

:v-if="foo"

--> console.warn("You specified v-bind:/ v-on: or a corresponding shorthand on a Vue attribute like v-if or similar. Usually this does not make sense.)

simonhermann avatar Jun 25 '19 10:06 simonhermann

I've seen this happen so often when teaching Vue that even though having a prop named vIf is technically valid, I think this warning would help much more people than ever hurt

posva avatar Jun 25 '19 12:06 posva

Yes. If you wanted a prop, why should have the same name as a v-attribute. That'd be incredibly confusing.

<ConfusingComponent 
  v-if="true"
  :v-if="false"
/>

simonhermann avatar Jun 25 '19 12:06 simonhermann

I'll take this on. It'll be my first issue here.

chrisdel101 avatar Jun 30 '19 19:06 chrisdel101

Thanks but as the tag suggest there is already a Pull request for this

posva avatar Jun 30 '19 19:06 posva

习惯就好

zvf618 avatar Sep 03 '19 08:09 zvf618

@simonhermann

WhiteDevill11 avatar Oct 25 '19 04:10 WhiteDevill11

I was going to give it a go but it seems there's a super old PR for this already

oielbanna avatar Dec 18 '20 02:12 oielbanna

Why is this issue still open?

amandesai01 avatar Mar 15 '22 09:03 amandesai01

Niu Bi

EdisonChenNanjing avatar Jun 08 '22 07:06 EdisonChenNanjing