devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Manually mouted component is not exposed in Vue Dev Tools

Open it-xtech-dev opened this issue 3 years ago • 8 comments

Version

5.3.4

Browser and OS info

Chrome 90.0.4430.93

Steps to reproduce

I'm mouting a component manually, just like docs says: https://vuejs.org/v2/api/#vm-mount

var MyComponent = Vue.extend({
  template: '<div>Hello!</div>'
})

// or, render off-document and append afterwards:
var component = new MyComponent().$mount()
document.getElementById('app').appendChild(component.$el)

What is expected?

I expect that component will be revealed in vue devtools component tree.

What is actually happening?

Component tree stays the same event when I referesh (in vue devtools menu)


Sandbox: https://4l3w20zomw.csb.app/ (based on article https://css-tricks.com/creating-vue-js-component-instances-programmatically/)

it-xtech-dev avatar Apr 28 '21 11:04 it-xtech-dev

I don't think we can actually handle this case. BTW in Vue 3 the app doesn't replace the DOM element anymore.

Akryum avatar Apr 28 '21 12:04 Akryum

:(

Is there any other legitimate way to add a component "dynamically" that will be recognized by vue dev tools?

it-xtech-dev avatar Apr 29 '21 06:04 it-xtech-dev

In the previous devtools version there was refresh button and if you hit that it would pick up vue apps that were manually mounted like this. Is that an option? I have a large app with many manually mounted vue apps. Its a Vue2 app btw.

pleek91 avatar May 14 '21 19:05 pleek91

      const ComponentClass = Vue.extend(app);
      instance = new ComponentClass({ parent: this, propsData: historyItem });
      instance.$mount();

you should pass parent instance, then you component will display in components tree

kikyous avatar May 26 '21 02:05 kikyous

@kikyous can you give a more detailed example? It seems like you're mounting an entire vue app which is what I'm doing. What is app and what context is this?

pleek91 avatar Aug 11 '21 03:08 pleek91

@Akryum it seems a little weird there isn't a way to handle this because devtools is aware at some extent of the component because if you use the select tool it will highlight the component and show its name. But when you click on it nothing happens (I assume because the app isn't registered in devtools).

pleek91 avatar Aug 11 '21 03:08 pleek91

@kikyous great

fyuanz avatar Sep 08 '21 06:09 fyuanz

Hello,

i'm using AgGridVue component and it does not show up in devtool (anonymous), what are the steps to make a third party imported component work with devtool ? i've tried to name it, but it says it's read only

thanks !

lk77 avatar Mar 08 '22 08:03 lk77