You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 6, 2021. It is now read-only.
A `converter` that formats regular dates in `xxx ago` or `in xxx` style.
72
72
73
73
Check out our [default converter](./src/converter.js) which uses [date-fns/distance_in_words_to_now](https://date-fns.org/v1.29.0/docs/distanceInWordsToNow) under the hood.
74
74
75
75
### converterOptions
76
76
77
-
-__Type__: `Object`
77
+
-**Type**: `Object`
78
78
79
79
Provide an object which will be available as argument `converterOptions` in the `converter` we mentioned above.
80
80
81
81
Our default converter supports most options that [date-fns/distance_in_words_to_now](https://date-fns.org/v1.29.0/docs/distanceInWordsToNow) library supports, namely:
82
82
83
-
-__includeSeconds__: (default: `false`) distances less than a minute are more detailed
84
-
-__addSuffix__: (default: `true`) result specifies if the second date is earlier or later than the first
83
+
-**includeSeconds**: (default: `false`) distances less than a minute are more detailed
84
+
-**addSuffix**: (default: `true`) result specifies if the second date is earlier or later than the first
85
85
86
86
## props
87
87
88
88
### datetime
89
89
90
-
-__Type__: `Date``string``number`
91
-
-__Required__: `true`
90
+
-**Type**: `Date``string``number`
91
+
-**Required**: `true`
92
92
93
93
The datetime to be formatted .
94
94
95
95
### autoUpdate
96
96
97
-
-__Type__: `number``boolean`
98
-
-__Default__: `false`
97
+
-**Type**: `number``boolean`
98
+
-**Default**: `false`
99
99
100
100
The period to update the component, in **seconds**.
101
101
@@ -115,6 +115,21 @@ Just like the `converter` option in the plugin options, but this could override
115
115
116
116
Just like the `converterOptions` option in the plugin options, but this could override the global one.
117
117
118
+
## Recipes
119
+
120
+
### Update Locale Globally
121
+
122
+
```js
123
+
Vue.use(VueTimeago, {
124
+
locale:"en",
125
+
locales: {
126
+
"zh-CN":require("date-fns/locale/zh_cn")
127
+
}
128
+
});
129
+
```
130
+
131
+
In your components you can use `this.$timeago.locale` to access the global locale, in this case it's `en`, the `<timeago>` component will get updated when you set it to another valid locale, e.g. `this.$timeago.locale = 'zh-CN'`.
132
+
118
133
## What about the good old [vue-timeago v3](https://github.com/egoist/vue-timeago/tree/3)?
119
134
120
135
The older version (700 bytes gzipped) is much smaller than the current version (2.8kB gzipped) that uses [`date-fns`](https://date-fns.org/).
<timeago:datetime="datetime2":locale="locale":autoUpdate="autoUpdate ? 1 : 0":converterOptions="{ includeSeconds: true }" /> <inputtype="checkbox"v-model="autoUpdate"> Auto Update in every second
18
+
<timeago:datetime="datetime2":autoUpdate="autoUpdate ? 1 : 0":converterOptions="{ includeSeconds: true }" /> <inputtype="checkbox"v-model="autoUpdate"> Auto Update in every second
0 commit comments