فهرست منبع

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

Evan You 1 سال پیش
والد
کامیت
a177092754
1فایلهای تغییر یافته به همراه2 افزوده شده و 1 حذف شده
  1. 2 1
      packages/runtime-core/src/helpers/useId.ts

+ 2 - 1
packages/runtime-core/src/helpers/useId.ts

@@ -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 ''
 }
 
 /**