• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • app.version

    提供创建应用程序时使用的 Vue 版本。这在 plugins 中很有用,您可能需要基于不同 Vue 版本的条件逻辑。

    类型

    interface App {
      version: string
    }
    


    例子

    在插件中执行版本检查:

    export default {
      install(app) {
        const version = Number(app.version.split('.')[0])
        if (version < 3) {
          console.warn('This plugin requires Vue 3')
        }
      }
    }
    

    上篇:app.directive()

    下篇:app.config