Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I disable certain Vue warnings for a specific component?

I have a (parent) component in Vue that ships with it's own on-screen keyboard which is in it's own Vue component. The keyboard keeps track of the entered value and passes this value to the parent component. Sometimes the parent component needs to reset the value.

The way it is currently implemented is by directly modifying the prop that is passed to the keyboard. That obviously yields the warning Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders.. However, this is exactly the behaviour I expect in this case: The variables are in sync, and should stay in sync if the parent changes the value. In other words: I want to disable this specific warning for this specific component.

I could add a watcher to the property that overwrites a local variable and use the local variable instead to keep track of things. That's... silly, as it does exactly what it does now, with more variables to keep track of. I have however not found a way to squelch warnings yet. Is there such a feature?

like image 392
Sumurai8 Avatar asked May 12 '17 08:05

Sumurai8


1 Answers

As per Linux Borg (core dev) it is currently (Vue 2.5.17) not possible to disable any warnings on a per-component basis. You can use the Vue.config.silent option to silence all warnings.

like image 101
Sumurai8 Avatar answered Sep 21 '22 17:09

Sumurai8