我可以禁用特定组件的某些 Vue 警告吗?

Can I disable certain Vue warnings for a specific component?

我在 Vue 中有一个(父)组件,它带有自己的屏幕键盘,位于它自己的 Vue 组件中。键盘会跟踪输入的值并将该值传递给父组件。有时父组件需要重新设置值。

目前的实现方式是直接修改传递给键盘的prop。这显然会产生警告 Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders.。然而,这正是我在这种情况下所期望的行为:变量是同步的,如果父级更改了值,它们应该保持同步。换句话说:我想禁用此特定组件的此特定警告。

我可以向 属性 添加一个观察器来覆盖局部变量并使用局部变量来跟踪事物。那是......愚蠢的,因为它完全按照现在的方式进行,需要跟踪更多变量。然而,我还没有找到抑制警告的方法。有没有这个功能?

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 关闭所有警告的选项。