konvajskonvavue-konva

Can't suppress Konva warnings in Vue


I'm using Konva in a Vue application, and I can't suppress Konva's warnings in browser console. According to Konva docs, there is an option for this, Konva.showWarnings = false. (I understood the warning itself and am aware of its possible implications).

I've checked this: Turn off Konvajs warnings, but to no avail, the answer here just explains that such a setting exists.

What I'm doing in my main.js file:

import VueKonva from 'vue-konva'
Vue.use(VueKonva)

and then I'm trying to apply the setting:

VueKonva.showWarnings = false

I've also tried adding it inside Vue.use as option:

Vue.use(VueKonva, {showWarnings: false})

...but to no avail.

What am I missing here?


Solution

  • You should do the same:

    import Konva from 'konva';
    Konva.showWarnings = false;
    

    Are you sure you want to disable them?

    edited: as the final solution to the problem, I'm adding @lavrton's comment from below: For the showWarnings property to work in vue-konva, you need to import both the original konva library, and the vue one for vue-bindings.

    The working code now looks like this:

    import VueKonva from "vue-konva";
    import Konva from "konva";
    Konva.showWarnings = false;
    
    Vue.use(VueKonva);
    Vue.use(Konva);