主题
useTimeAgoIntl
支持 i18n 的实时显示时间功能。当时间变化时,时间显示字符串会自动更新。由 Intl.RelativeTimeFormat 提供支持。
🌐 Reactive time ago with i18n supported. Automatically update the time ago string when the time changes. Powered by Intl.RelativeTimeFormat.
示例
用法
🌐 Usage
js
import { useTimeAgoIntl } from '@vueuse/core'
const timeAgoIntl = useTimeAgoIntl(new Date(2021, 0, 1))非反应式用法
🌐 Non-Reactivity Usage
如果你不需要响应性,可以使用 formatTimeAgo 函数获取格式化字符串,而不是 Ref。
🌐 In case you don't need the reactivity, you can use the formatTimeAgo function to get the formatted string instead of a Ref.
js
import { formatTimeAgoIntl } from '@vueuse/core'
const timeAgoIntl = formatTimeAgoIntl(new Date(2021, 0, 1)) // string