Skip to content

Commit 74eccb0

Browse files
fix(vue3): Optimize the priority of calculating the displayed name of the component on the devtool (#2050)
1 parent 1b1d1d0 commit 74eccb0

File tree

1 file changed

+8
-4
lines changed
  • packages/app-backend-vue3/src/components

1 file changed

+8
-4
lines changed

packages/app-backend-vue3/src/components/util.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export function getInstanceName (instance) {
3636
for (const key in instance.appContext?.components) {
3737
if (instance.appContext.components[key] === instance.type) return saveComponentName(instance, key)
3838
}
39+
const fileName = getComponentFileName(instance.type || {})
40+
if (fileName) {
41+
return fileName
42+
}
3943
return 'Anonymous Component'
4044
}
4145

@@ -45,10 +49,10 @@ function saveComponentName (instance, key) {
4549
}
4650

4751
function getComponentTypeName (options) {
48-
const name = options.name || options._componentTag || options.__vdevtools_guessedName || options.__name
49-
if (name) {
50-
return name
51-
}
52+
return options.name || options._componentTag || options.__vdevtools_guessedName || options.__name
53+
}
54+
55+
function getComponentFileName (options) {
5256
const file = options.__file // injected by vue-loader
5357
if (file) {
5458
return classify(basename(file, '.vue'))

0 commit comments

Comments
 (0)