How to check if an object is a component of Vue?

Is there a reliable way to check if an object is a component of Vue.js?

+4
source share
1 answer

You can use instanceof as the following code:

var isVueComp = vuecomp instanceof Vue

If the value is isVueComptrue, it is not Vue.js componenteny, not.

You can also use vuecomp.prototype.constructor , which will return a reference to the constructor function of the object that created the instance object.

Check the fiddle .

+3
source

Source: https://habr.com/ru/post/1671589/


All Articles