File tree Expand file tree Collapse file tree
app-backend-vue3/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,13 +29,23 @@ export function isFragment (instance) {
2929export function getInstanceName ( instance ) {
3030 const name = getComponentTypeName ( instance . type || { } )
3131 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
3545}
3646
3747function getComponentTypeName ( options ) {
38- const name = options . name || options . _componentTag
48+ const name = options . name || options . _componentTag || options . __vdevtools_guessedName
3949 if ( name ) {
4050 return name
4151 }
Original file line number Diff line number Diff line change @@ -26,9 +26,18 @@ for (let i = 0; i < 100; i++) {
2626const circular = { }
2727circular . self = circular
2828
29+ Vue . component ( 'global' , {
30+ render : h => h ( 'h3' , 'Global component' )
31+ } )
32+
2933const app = new Vue ( {
3034 store,
3135 router,
36+ components : {
37+ inline : {
38+ render : h => h ( 'h3' , 'Inline component definition' )
39+ }
40+ } ,
3241 data : {
3342 obj : {
3443 items : items ,
@@ -47,7 +56,9 @@ const app = new Vue({
4756 h ( VuexObject ) ,
4857 h ( Init ) ,
4958 h ( RefTester ) ,
50- h ( Hidden )
59+ h ( Hidden ) ,
60+ h ( 'global' ) ,
61+ h ( 'inline' )
5162 ] )
5263 }
5364} )
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ import SetupRender from './SetupRender.js'
1515import Form from ' ./Form.vue'
1616import Heavy from ' ./Heavy.vue'
1717
18+ import { h } from ' vue'
19+
1820export default {
1921 name: ' MyApp' ,
2022
@@ -33,7 +35,10 @@ export default {
3335 Other,
3436 SetupRender,
3537 Form,
36- Heavy
38+ Heavy,
39+ inline: {
40+ render : () => h (' h3' , ' Inline component definition' )
41+ }
3742 },
3843
3944 data () {
@@ -77,6 +82,8 @@ export default {
7782 <Other />
7883 <SetupRender />
7984 <Form />
85+ <inline />
86+ <global />
8087
8188 <nav >
8289 <router-link to =" /p1" >
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ const router = createRouter({
2323} )
2424
2525const app = createApp ( App )
26+ app . component ( 'global' , {
27+ render : ( ) => 'I\'m a global component'
28+ } )
2629app . use ( TestPlugin )
2730app . use ( router )
2831app . mount ( '#app' )
You can’t perform that action at this time.
0 commit comments