UNPKG
@element-plus-next/vue-hooks
Version:
latest (3.0.0-alpha.5)
3.0.0-alpha.5
Vue hooks for Element Plus.
element-plus.org
element-plus/element-plus
@element-plus-next/vue-hooks
/
src
/
use-prop
/
index.ts
8 lines
(6 loc)
•
272 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
import
{ computed, getCurrentInstance }
from
'vue'
import
type
{
ComputedRef
}
from
'vue'
export
const
useProp = <T>(
name
:
string
):
ComputedRef
<T |
undefined
> => {
const
vm =
getCurrentInstance
()!
return
computed
(
() =>
(vm.
proxy
?.
$props
as
any
)[name] ??
undefined
) }