File tree Expand file tree Collapse file tree 4 files changed +37
-6
lines changed
app-backend-vue3/src/components Expand file tree Collapse file tree 4 files changed +37
-6
lines changed Original file line number Diff line number Diff line change @@ -29,13 +29,23 @@ export function isFragment (instance) {
29
29
export function getInstanceName ( instance ) {
30
30
const name = getComponentTypeName ( instance . type || { } )
31
31
if ( name ) return name
32
- return instance . root === instance
33
- ? 'Root'
34
- : 'Anonymous Component'
32
+ if ( instance . root === instance ) return 'Root'
33
+ for ( const key in instance . parent ?. type ?. components ) {
34
+ if ( instance . parent . type . components [ key ] === instance . type ) return saveComponentName ( instance , key )
35
+ }
36
+ for ( const key in instance . appContext ?. components ) {
37
+ if ( instance . appContext . components [ key ] === instance . type ) return saveComponentName ( instance , key )
38
+ }
39
+ return 'Anonymous Component'
40
+ }
41
+
42
+ function saveComponentName ( instance , key ) {
43
+ instance . type . __vdevtools_guessedName = key
44
+ return key
35
45
}
36
46
37
47
function getComponentTypeName ( options ) {
38
- const name = options . name || options . _componentTag
48
+ const name = options . name || options . _componentTag || options . __vdevtools_guessedName
39
49
if ( name ) {
40
50
return name
41
51
}
Original file line number Diff line number Diff line change @@ -26,9 +26,18 @@ for (let i = 0; i < 100; i++) {
26
26
const circular = { }
27
27
circular . self = circular
28
28
29
+ Vue . component ( 'global' , {
30
+ render : h => h ( 'h3' , 'Global component' )
31
+ } )
32
+
29
33
const app = new Vue ( {
30
34
store,
31
35
router,
36
+ components : {
37
+ inline : {
38
+ render : h => h ( 'h3' , 'Inline component definition' )
39
+ }
40
+ } ,
32
41
data : {
33
42
obj : {
34
43
items : items ,
@@ -47,7 +56,9 @@ const app = new Vue({
47
56
h ( VuexObject ) ,
48
57
h ( Init ) ,
49
58
h ( RefTester ) ,
50
- h ( Hidden )
59
+ h ( Hidden ) ,
60
+ h ( 'global' ) ,
61
+ h ( 'inline' )
51
62
] )
52
63
}
53
64
} )
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ import SetupRender from './SetupRender.js'
15
15
import Form from ' ./Form.vue'
16
16
import Heavy from ' ./Heavy.vue'
17
17
18
+ import { h } from ' vue'
19
+
18
20
export default {
19
21
name: ' MyApp' ,
20
22
@@ -33,7 +35,10 @@ export default {
33
35
Other,
34
36
SetupRender,
35
37
Form,
36
- Heavy
38
+ Heavy,
39
+ inline: {
40
+ render : () => h (' h3' , ' Inline component definition' )
41
+ }
37
42
},
38
43
39
44
data () {
@@ -77,6 +82,8 @@ export default {
77
82
<Other />
78
83
<SetupRender />
79
84
<Form />
85
+ <inline />
86
+ <global />
80
87
81
88
<nav >
82
89
<router-link to =" /p1" >
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ const router = createRouter({
23
23
} )
24
24
25
25
const app = createApp ( App )
26
+ app . component ( 'global' , {
27
+ render : ( ) => 'I\'m a global component'
28
+ } )
26
29
app . use ( TestPlugin )
27
30
app . use ( router )
28
31
app . mount ( '#app' )
You can’t perform that action at this time.
0 commit comments