useToString
将 ref 响应式地转换为字符串。
用法
ts
import { useToString } from '@vueuse/core'
import { shallowRef } from 'vue'
const number = shallowRef(3.14)
const str = useToString(number)
str.value // '3.14'
类型声明
typescript
/**
* Reactively convert a ref to string.
*
* @see https://vueuse.org.cn/useToString
*/
export declare function useToString(
value: MaybeRefOrGetter<unknown>,
): ComputedRef<string>
源码
贡献者
更新日志
v12.8.0
于 3/5/2025v12.3.0
于 1/2/202559f75
- feat(toValue): 弃用 toValue
从 @vueuse/shared
以支持 Vue 的原生v12.0.0-beta.1
于 11/21/2024v10.0.0-beta.4
于 4/13/20234d757
- feat(types)!: 将 MaybeComputedRef
重命名为 MaybeRefOrGetter
0a72b
- feat(toValue): 将 resolveUnref
重命名为 toValue