Subscribe on changes!

Disabling warnings about inline value attributes for v-model

avatar
Apr 13th 2021

Version

3.0.11

Steps to reproduce

Open the following:

https://jsfiddle.net/zqystjur/

The following warning will be thrown:

[Vue warn]: Template compilation error: Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.


This seems to relate to the following Vue 2 issue:

https://github.com/vuejs/vue/issues/4733

avatar
Apr 13th 2021

What about when using :value alongside the value attribute? From my understanding v-model is shorthand for :value="foo" @input="foo = $event.target.value". However when using :value it doesn't seem to override the value attribute unlike v-model. See the following for an example:

https://jsfiddle.net/s2orke8c/

No warning is thrown but maybe one should be thrown in this case, unless this is a bug.

avatar
Apr 13th 2021

@phanan I think your input would be valuable here

avatar
Apr 13th 2021

Hmm, TBH I'm not sure why this 1.x behavior was revived in v3, but I still tend to agree with 4-year-ago me 😄 that this warning isn't extremely helpful. Again, as the original v2 issue author said, there are frameworks/libraries/CMSes that generate inline value attributes, which would cause this warning to be thrown all over the place. I'd vote for removal.

avatar
Apr 13th 2021

what about :value and this proposal

avatar
Apr 14th 2021

AFAIU there's no warning for :value, which is expected right? But I'd tend to agree that :value not overriding value sounds weird. Maybe @yyx990803 can shed a light on both topics here?

avatar
Apr 14th 2021

Now that I read the comment again, I was more thinking of a :value with a v-model throwing a warning instead of any value attribute with a v-model

avatar
Apr 14th 2021

That makes perfect sense @posva. The two bindings with conflicting effects should have a warning. Binding vs static shouldn't.

avatar
Apr 14th 2021

I personally feel that :value should override the value attribute (to be consistent with v-model). But I agree it makes sense to throw a warning if :value is used with v-model.

avatar
May 10th 2021

It seems the order of the attributes is important. See the following:

https://jsfiddle.net/xm270v6y/

Therefore my new conclusion is that it should throw a warning if :value is used with v-model or :value is used after a value attribute (but not before).

There is a similar issue when using v-text and v-html attribute's on elements which contains server-side rendered content. See the following example:

https://jsfiddle.net/jbfqsgd1/

Once again I feel these warnings are counter intuitive and actually discourage one of the great features of Vue in that you can render an initial value (which matches the data-bound value) and have Vue later override it. One use case for this is for multi-page applications where I have replaced some of the jQuery plugins with Vue components. If the server-side rendered code doesn't match the output after the Vue instance is mounted then there will be a flicker as the content changes.

avatar
Jul 6th 2021

I've been looking at petite-vue this weekend and that's exactly how I've been using Vue. This is why I believe these warnings should be removed since they interfere with SSR and Vue should ideally be a superset of Petite-Vue.

avatar
Jan 6th 2022

Any update on this? Another idea would be to add a config option to ignore particular warnings.

avatar
Oct 23rd 2023

Any update on this for 2023? It would be great to be able to control this warning.