fix(runtime-core): make useId() always return a string

This commit is contained in:
Evan You 2024-09-23 08:38:24 +08:00
parent 5e8898572f
commit a177092754
No known key found for this signature in database
GPG Key ID: 00E9AB7A6704CE0A
1 changed files with 2 additions and 1 deletions

View File

@ -4,7 +4,7 @@ import {
} from '../component'
import { warn } from '../warning'
export function useId(): string | undefined {
export function useId(): string {
const i = getCurrentInstance()
if (i) {
return (i.appContext.config.idPrefix || 'v') + '-' + i.ids[0] + i.ids[1]++
@ -14,6 +14,7 @@ export function useId(): string | undefined {
`instance to be associated with.`,
)
}
return ''
}
/**