Skip to content

Commit 4a437b6

Browse files
docs: add Vue.version and app.version to the API reference (#999)
1 parent d622347 commit 4a437b6

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/api/application-api.md

+24
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,27 @@ setTimeout(() => app.unmount(), 5000)
316316
```
317317

318318
- **See also:** [Plugins](../guide/plugins.html)
319+
320+
## version
321+
322+
- **Usage:**
323+
324+
Provides the installed version of Vue as a string. This is especially useful for community [plugins](/guide/plugins.html), where you might use different strategies for different versions.
325+
326+
- **Example:**
327+
328+
```js
329+
export default {
330+
install(app) {
331+
const version = Number(app.version.split('.')[0])
332+
333+
if (version < 3) {
334+
console.warn('This plugin requires Vue 3')
335+
}
336+
337+
// ...
338+
}
339+
}
340+
```
341+
342+
- **See also**: [Global API - version](/api/global-api.html#version)

src/api/global-api.md

+18
Original file line numberDiff line numberDiff line change
@@ -532,3 +532,21 @@ Accepts one argument: `name`
532532
- **Details:**
533533

534534
The name of the CSS module. Defaults to `'$style'`.
535+
536+
## version
537+
538+
Provides the installed version of Vue as a string.
539+
540+
```js
541+
const version = Number(Vue.version.split('.')[0])
542+
543+
if (version === 3) {
544+
// Vue 3
545+
} else if (version === 2) {
546+
// Vue 2
547+
} else {
548+
// Unsupported versions of Vue
549+
}
550+
```
551+
552+
**See also**: [Application API - version](/api/application-api.html#version)

0 commit comments

Comments
 (0)