mirror of https://github.com/vuejs/core.git
fix(runtime-core): make useId() always return a string
This commit is contained in:
parent
5e8898572f
commit
a177092754
|
@ -4,7 +4,7 @@ import {
|
||||||
} from '../component'
|
} from '../component'
|
||||||
import { warn } from '../warning'
|
import { warn } from '../warning'
|
||||||
|
|
||||||
export function useId(): string | undefined {
|
export function useId(): string {
|
||||||
const i = getCurrentInstance()
|
const i = getCurrentInstance()
|
||||||
if (i) {
|
if (i) {
|
||||||
return (i.appContext.config.idPrefix || 'v') + '-' + i.ids[0] + i.ids[1]++
|
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.`,
|
`instance to be associated with.`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue