diff --git a/src/api/application-api.md b/src/api/application-api.md index cc37f188cc..63a7597eb6 100644 --- a/src/api/application-api.md +++ b/src/api/application-api.md @@ -316,3 +316,27 @@ setTimeout(() => app.unmount(), 5000) ``` - **See also:** [Plugins](../guide/plugins.html) + +## version + +- **Usage:** + + 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. + +- **Example:** + + ```js + export default { + install(app) { + const version = Number(app.version.split('.')[0]) + + if (version < 3) { + console.warn('This plugin requires Vue 3') + } + + // ... + } + } + ``` + +- **See also**: [Global API - version](/api/global-api.html#version) diff --git a/src/api/global-api.md b/src/api/global-api.md index 1f257d7a59..15709a6f7f 100644 --- a/src/api/global-api.md +++ b/src/api/global-api.md @@ -532,3 +532,21 @@ Accepts one argument: `name` - **Details:** The name of the CSS module. Defaults to `'$style'`. + +## version + +Provides the installed version of Vue as a string. + +```js +const version = Number(Vue.version.split('.')[0]) + +if (version === 3) { + // Vue 3 +} else if (version === 2) { + // Vue 2 +} else { + // Unsupported versions of Vue +} +``` + +**See also**: [Application API - version](/api/application-api.html#version)