File tree 1 file changed +22
-3
lines changed 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
- import type { Component } from 'vue'
1
+ import type { Component , App as VueAppType } from 'vue'
2
2
import { createApp , h } from 'vue'
3
-
4
3
import App from './App.vue'
5
4
5
+ let app : VueAppType
6
6
function createDevToolsContainer ( App : Component ) {
7
7
const CONTAINER_ID = '__vue-devtools-container__'
8
8
const el = document . createElement ( 'div' )
9
9
el . setAttribute ( 'id' , CONTAINER_ID )
10
10
el . setAttribute ( 'data-v-inspector-ignore' , 'true' )
11
11
document . getElementsByTagName ( 'body' ) [ 0 ] . appendChild ( el )
12
- const app = createApp ( {
12
+ app = createApp ( {
13
13
render : ( ) => h ( App ) ,
14
14
devtools : {
15
15
hide : true ,
@@ -19,3 +19,22 @@ function createDevToolsContainer(App: Component) {
19
19
}
20
20
21
21
createDevToolsContainer ( App )
22
+
23
+ const targetNode = document . body
24
+ const config = { childList : true , attributes : false }
25
+ const observer = new MutationObserver ( callback )
26
+ observer . observe ( targetNode , config )
27
+
28
+ let init = false
29
+ function callback ( mutationsList , observer ) {
30
+ for ( const mutation of mutationsList ) {
31
+ if ( mutation . type === 'childList' && init === false ) {
32
+ if ( app ) {
33
+ app . unmount ( )
34
+ }
35
+ createDevToolsContainer ( App )
36
+ init = true
37
+ observer . disconnect ( )
38
+ }
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments