#版本和迁移

Vuetify 团队每周执行一次发布。 所有发行说明都可以通过 Github 找到,并可以在下面查看以便于您使用。 此外,在主要版本之间,可能会有许多重大更改,您可以在其中遵循以下最新的迁移指南,以帮助您轻松进行过渡。

发布说明

v2.2.26

🔧 Bug Fixes

迁移指南

Migrating from v1.5.x to v2.0.x

Version 2 contains non backwards compatible breaking changes. This includes previously deprecated functionality from v1.x.x. These breaking changes are noted in the console for the corresponding components.

The existing grid is still operational and has an eslint plugin to help with migration. This plugin can also be used to help upgrade to the new grid.

Bootstrap

Vuetify must now be instantiated and passed to the initial Vue instance. This is similar to how vue-router and vuex are bootstrapped.

Vue-CLI 3 Vuetify plugin install

  1. // v1.5
  2. // src/plugins/vuetify.js
  3. import Vue from 'vue'
  4. import Vuetify from 'vuetify/lib'
  5. import 'vuetify/src/stylus/app.styl'
  6. Vue.use(Vuetify, {
  7. iconfont: 'md',
  8. })
  9. // src/main.js
  10. import Vue from 'vue'
  11. import './plugins/vuetify'
  12. import App from './App.vue'
  13. Vue.config.productionTip = false
  14. new Vue({
  15. render: h => h(App),
  16. }).$mount('#app')
  1. // v2.0
  2. // src/plugins/vuetify.js
  3. import Vue from 'vue';
  4. import Vuetify from 'vuetify/lib';
  5. Vue.use(Vuetify);
  6. export default new Vuetify({
  7. icons: {
  8. iconfont: 'mdi',
  9. },
  10. });
  11. // src/main.js
  12. import Vue from 'vue'
  13. import App from './App.vue'
  14. import vuetify from './plugins/vuetify';
  15. Vue.config.productionTip = false
  16. new Vue({
  17. vuetify,
  18. render: h => h(App)
  19. }).$mount('#app')

Full Install

  1. // v1.5
  2. import Vue from 'vue'
  3. import Vuetify from 'vuetify'
  4. import 'vuetify/src/stylus/main.styl'
  5. const opts = { ... }
  6. Vue.use(Vuetify, opts)
  7. new Vue(...).$mount('#app')
  1. // v2.0
  2. import Vue from 'vue'
  3. import Vuetify from 'vuetify'
  4. import 'vuetify/dist/vuetify.min.css'
  5. const opts = { ... }
  6. Vue.use(Vuetify)
  7. new Vue({
  8. vuetify: new Vuetify(opts)
  9. }).$mount('#app')

A-La-Carte Install (vuetify-loader)

  1. // v1.5
  2. import Vue from 'vue'
  3. import Vuetify from 'vuetify/lib'
  4. import 'vuetify/src/stylus/main.styl'
  5. const opts = { ... }
  6. Vue.use(Vuetify, opts)
  7. new Vue(...).$mount('#app')
  1. // v2.0
  2. import Vue from 'vue'
  3. import Vuetify from 'vuetify/lib'
  4. const opts = { ... }
  5. Vue.use(Vuetify)
  6. new Vue({
  7. vuetify: new Vuetify(opts)
  8. }).$mount('#app')

Framework

The following components are now lazy by default. This means they will not render their content until they are explicitly activated. This drastically improves performance but may not be wanted depending upon your application’s needs (i.e. For SEO purposes). To return to the previous behavior, use the eager prop.

  • v-badge
  • v-menu
  • v-tooltip
  • v-dialog
  • v-bottom-sheet

vuetify/lib is now compiled to es6. This means supporting IE requires transpileDependencies or similar to be used, along with @babel/polyfill. Transpile dependencies are automatically added when using vue-cli-3. If you have an older version, you can simple add ‘vuetify’ to the list.

Theme

Now supports dark/light theme variants. The dark property has been moved into the theme property. Will dynamically change when toggling $vuetify.theme.dark. If only using one variant, you only need to define its colors.

  1. // v1.5
  2. const opts = {
  3. dark: true,
  4. theme: {
  5. primary: '...',
  6. ...
  7. }
  8. }
  1. // v2.0
  2. const opts = {
  3. theme: {
  4. dark: true,
  5. themes: {
  6. light: {
  7. primary: '...',
  8. ...
  9. },
  10. dark: {
  11. primary: '...',
  12. ...
  13. }
  14. }
  15. }
  16. }

In order to disable the theme style sheet creation, you must use the disable property of the theme object.

  1. // v1.5
  2. const opts = {
  3. theme: false
  4. }
  1. // v2.0
  2. const opts = {
  3. theme: { disable: true }
  4. }

Icons

Icon and iconfont declaration is now scoped under the icons property.

  1. // v1.5
  2. const opts = {
  3. iconfont: 'fa4',
  4. icons: { ... }
  5. }
  1. // v2.0
  2. const opts = {
  3. icons: {
  4. iconfont: 'fa4',
  5. values: { ... }
  6. }
  7. }
  • Now defaults to use mdi icons. For information on how to install please navigate here
  • Is now located under the icons property of the Vuetify options

If you want to use a custom iconfont, you must set it up in the initial Vuetify options now.

  1. // v1.5
  2. import Vue from 'vue'
  3. import Vuetify from 'vuetify'
  4. Vue.use(Vuetify, {
  5. iconfont: 'fa4'
  6. })
  1. // v2.0
  2. import Vue from 'vue'
  3. import Vuetify from 'vuetify'
  4. Vue.use(Vuetify, {
  5. icons: {
  6. iconfont: 'fa4'
  7. }
  8. })

Goto (scrolling helper)

Import location has changed. Must be explicitly bootstrapped with the Vuetify instance to use in vue-router scroll-behavior. Example of how to do this here. Reference documentation for scroll-behavior usage here.

  1. // v1.5
  2. import goTo from 'vuetify/es5/components/Vuetify/goTo'
  1. // v2.0
  2. import goTo from 'vuetify/lib/services/goto'

Lang

The translator function t is now nested under the lang property.

  1. // v1.5
  2. this.$vuetify.t(...)
  1. // v2.0
  2. this.$vuetify.lang.t(...)

Grid

The grid has been rebuilt modeled after bootstrap. The existing grid still works and needs some slight modifications. Kael has created an eslint plugin to help with this process.

  • eslint-plugin-vuetify to fix most of these for you
  • Spacing helpers have changed to represent the number of 4px intervals from 0-12 (0-48px)
    • eg. px-7 is 7 * 4 = 28px
    • 3 → 4
    • 4 → 6
    • 5 → 12
  • Most “breakpointed” and “non-breakpointed” helpers have been normalised, eg. .text-xs-center is now text-center as it applies to all screen widths unless overridden
  • Children of .d-flex no longer have extra flex rules applied. This can be done manually with .flex-grow-1
  • Helper classes changed:
    • .fluid.container--fluid
    • .scroll-y.overflow-y-auto
    • .hide-overflow.overflow-hidden
    • .show-overflow.overflow-visible
    • .no-wrap.text-no-wrap
    • .ellipsis.text-truncate
    • .left.float-left
    • .right.float-right
  • <v-layout row> should not be used as .row is now part of the new grid instead (#7956)

Use the following regex to update spacing classes:

  1. find: ([\s"][mp][axytblr])-5
  2. replace: $1-12
  3. find: ([\s"][mp][axytblr])-4
  4. replace: $1-6
  5. find: ([\s"][mp][axytblr])-3
  6. replace: $1-4

For examples on how the v2 grid compares to v1.5, check out this github gist.

Styles

The main framework styles are now imported automatically.

  1. // v1.5
  2. // src/plugins/vuetify.js
  3. import 'vuetify/src/styles/main.sass' // can be removed

Must install the sass package

  1. yarn add sass -D
  2. // OR
  3. npm install sass -D

Do not install node-sass, it is not the correct library.

Typography

The root font-size (per MD2 specification) is now 16px.

  • The following typography classes have been replaced:
    • subheading → subtitle-1

Event names

All event names has been changed from camelCase to kebab-case:

  • update:searchInputupdate:search-input
  • update:inputValueupdate:input-value
  • update:miniVariantupdate:mini-variant
  • update:pickerDateupdate:picker-date
  • update:selectingYearupdate:selecting-year
  • tableDateupdate:table-date
  • update:returnValueupdate:return-value

Activators

  • Components with activators, v-tooltip, v-menu, v-dialog, v-list-group and v-bottom-sheet must now be bound using the new v-slot syntax
  • We understand this is considerably more verbose than the v1.5 counterpart. We are still exploring ways to support the new v-slot in a more concise manner
    • You can find more information on the official Vue documentation for Destructuring Slot Props
    • You can find more information on the official Vue documentation for v-slot
  • The upside to this change is it is easier to support nested activators and provide proper a11y support

Regular activator

  1. <!-- v1.5 -->
  2. <v-dialog>
  3. <v-btn slot="activator">...</v-btn>
  4. </v-dialog>
  1. <!-- v2.0 -->
  2. <v-dialog>
  3. <template v-slot:activator="{ on }">
  4. <v-btn v-on="on">...</v-btn>
  5. </template>
  6. </v-dialog>

Nested activator

  1. <!-- v2.0 -->
  2. <v-menu>
  3. <template v-slot:activator="{ on: menu }">
  4. <v-tooltip bottom>
  5. <template v-slot:activator="{ on: tooltip }">
  6. <v-btn
  7. color="primary"
  8. dark
  9. v-on="{ ...tooltip, ...menu }"
  10. >
  11. Dropdown w/ Tooltip
  12. </v-btn>
  13. </template>
  14. <span>Im A ToolTip</span>
  15. </v-tooltip>
  16. </template>
  17. </v-menu>

Unit tests

Testing with Vuetify is now similar to that of vue-router and vuex.

  1. // setup.js
  2. import Vue from 'vue'
  3. import Vuetify from 'vuetify'
  4. Vue.use(Vuetify)
  1. // Component.spec.js
  2. import { createLocalVue, mount } from '@vue/test-utils'
  3. import Vuetify from 'vuetify'
  4. import Component from 'path/to/my/component'
  5. const localVue = createLocalVue()
  6. describe('Component.vue', () => {
  7. let vuetify
  8. beforeEach(() => {
  9. vuetify = new Vuetify(...)
  10. })
  11. it('should...', () => {
  12. const wrapper = mount(Component, {
  13. localVue,
  14. vuetify
  15. })
  16. })
  17. })

Form Input Validation

All form inputs default to white when using the dark prop unless the application is explicitly set to dark mode.

Removed Component Properties

These are previous deprecations from earlier versions that have now been removed:

  • <v-text-field textarea> will no longer render <v-textarea>
  • <v-select autocomplete> will no longer render <v-autocomplete>
  • <v-select combobox> will no longer render <v-combobox>
  • <v-select overflow> will no longer render <v-overflow-btn>
  • <v-select segmented> will no longer render <v-overflow-btn segmented>
  • <v-select editable> will no longer render <v-overflow-btn editable>

Individual Components

These are the changes required for existing components.

v-app

  • Component classes have been prepended with v-. eg .application.v-application
  • The dark and light prop no longer have an effect on application theme variants
  1. <!-- v1.5 src/App.vue -->
  2. <template>
  3. <v-app dark>
  4. ...
  5. </v-app>
  6. </template>
  1. // v2.0 src/plugins/vuetify.js
  2. import Vue from 'vue'
  3. import Vuetify from 'vuetify'
  4. Vue.use(Vuetify)
  5. export default new Vuetify({
  6. theme: { dark: true }
  7. })

v-alert

  • Alerts are visible by default
  1. <!-- v1.5 -->
  2. <template>
  3. <v-alert :value="true">
  4. ...
  5. </v-alert>
  6. </template>
  1. <!-- v2.0 -->
  2. <template>
  3. <v-alert>
  4. ...
  5. </v-alert>
  6. </template>

v-carousel

  • The cycle prop is no longer implicit, must be defined in order to have screens switch

v-btn

  • The flat prop is now text
  • The round prop is now rounded
  • No longer has explicit margin

v-chip

  • value no longer controls visibility, use active
  • input event emitted when clicking
  • The close event is now click:close
  • @input listener is now @active.sync
  1. <!-- v1.5 -->
  2. <v-chip :value="chip" @input="chip = $event">...</v-chip>
  3. <v-chip v-model="chip">...</v-chip>
  1. <!-- v2.0 -->
  2. <v-chip :active="chip" @update:active="chip = $event">...</v-chip>
  3. <v-chip :active.sync="active">...</v-chip>

v-bottom-nav

  • Renamed from v-bottom-nav to v-bottom-navigation

v-bottom-navigation

  • The color prop is now background-color
  • The color prop now affects the active <v-btn> color

v-bottom-sheet-transition

  • Component has been removed

Developer notes: Was never explicitly listed in API

v-btn

  • The flat prop is now text
  • The round prop is now rounded
  • No longer has explicit margin

v-card-media

  • Component has been removed

v-carousel

  • The cycle prop is no longer implicit, must be defined in order to have screens switch

v-chip

  • The value prop is now active
  • value no longer controls visibility. input event emitted when clicking
  • The selected prop is now input-value or v-model
  • The close event is now click:close

v-data-iterator & v-data-table

Data table (and iterator) have been rewritten from the ground up to be both easier to use and to allow for more flexibilty in more advanced use cases. This has resulted in a number of breaking changes. Some of these are shared between both components while some are unique to each.

Shared

  • disable-initial-sort has been removed. Neither component initially sorts data anymore. Use sort-by (or options) prop to sort
  • filter prop has been removed. Instead use custom-filter. This was done in an effort to make custom filtering less confusing
    • The signature for custom-filter has changed from (items: object[], search: string, filter: Filter): object[] to (value: any, search: string, item: any) => boolean
  • pagination prop has been removed. Instead use the separate props such as page, sort-by, etc. If you want to provide a single object you can use the new options prop instead. NOTE: The options prop has a different object structure than pagination. Check API docs for details
  • total-items prop has been renamed to server-items-length
  • hide-actions prop has been renamed to hide-default-footer. Also it no longer changes the visible items per page
  • Props related to the default footer have been move to the footer-props prop. These are:
    • prev-icon
    • next-icon
    • rows-per-page-itemsitems-per-page-options
    • rows-per-page-textitems-per-page-text
  • The expand prop has been removed

v-data-iterator

  • The content-tag, content-props, content-class props have been removed. Instead simply use the default scoped slot to implement your intended markup.

v-data-table

  • items slot has been renamed to item
  • headers slot renamed to header
  • item slot (and header) now require you to define a <tr> element. Previously this was optional
  • expand slot renamed to expanded-item. It no longer includes an expansion transition, and the slot is inside the <tr> element so that you can define your own <td> columns. To get back to a similar look as in 1.5, you will need a <td> with colspan equal to the number of columns in your header
  • hide-header has been renamed to hide-default-header
  • select-all has been renamed to show-select. This will also render a checkbox on each item row as long as you are not defining a slot that overrides the internal row rendering (such as item or body)
  • Props related to the default header have been moved to the header-props prop. These are:
    • sort-icon

v-expansion-panel et al

  • Many components have been renamed and props moved
    • v-expansion-panelv-expansion-panels
    • v-expansion-panel-contentv-expansion-panel
  • New components
    • v-expansion-panel-header
    • v-expansion-panel-content
  1. <!-- v1.5 -->
  2. <v-expansion-panel>
  3. <v-expansion-panel-content
  4. v-for="(item,i) in 5"
  5. :key="i"
  6. >
  7. <template v-slot:header>Item</template>
  8. <v-card>
  9. ...
  10. </v-card>
  11. </v-expansion-panel-content>
  12. </v-expansion-panel>
  1. <!-- v2.0 -->
  2. <v-expansion-panels>
  3. <v-expansion-panel
  4. v-for="(item,i) in 5"
  5. :key="i"
  6. >
  7. <v-expansion-panel-header>
  8. Item
  9. </v-expansion-panel-header>
  10. <v-expansion-panel-content>
  11. <v-card>
  12. ...
  13. </v-card>
  14. </v-expansion-panel-content>
  15. </v-expansion-panel>
  16. </v-expansion-panels>

v-footer

  • Now has explicit padding to match other similar MD components. Can be removed with the padless prop or a helper class, class="pa-0"

v-jumbotron

  • Component has been removed

v-list et al

  • Many components have been renamed
    • v-list-tilev-list-item
    • v-list-tile-actionv-list-item-action
    • v-list-tile-avatarv-list-item-avatar
    • v-list-tile-contentv-list-item-content
    • v-list-tile-titlev-list-item-title
    • v-list-tile-sub-titlev-list-item-subtitle
    • The avatar prop has been removed

v-list-group

  • Can no longer use v-list-items in the activator slot
    • listeners are passed through to the internal v-list-item for activators
    • use v-list-item-content/v-list-item-title etc instead

v-navigation-drawer

  • Default width has been changed from 300px to 256px. You can adjust it using width prop.

v-select, v-autocomplete, v-combobox, v-overflow-btn

  • Now passes attributes and listeners to item slot for proper a11y support (split from tile to match other implementations).
  1. <!-- v1.5 -->
  2. <v-select>
  3. <template v-slot:item="{ item, tile }">
  4. <v-list-tile v-bind="tile">
  5. ...
  6. </v-list-tile>
  7. </template>
  8. </v-select>
  1. <!-- v2.0 -->
  2. <v-select>
  3. <template v-slot:item="{ item, attrs, on }">
  4. <v-list-item v-bind="attrs" v-on="on">
  5. ...
  6. </v-list-item>
  7. </template>
  8. </v-select>

The item scoped slot value of { tile } is now{ attrs, on }. is now bound similar to the v-menu activator slot.

v-select

  • No longer has a default autocomplete of on

v-speed-dial

  • Icons no longer have inferred swapping for activator through css
  • The activator slot will provide a model in the future
  1. <!-- v1.5 -->
  2. <v-speed-dial>
  3. <template v-slot:activator>
  4. <v-btn
  5. dark
  6. fab
  7. >
  8. <v-icon>account_circle</v-icon>
  9. <v-icon>close</v-icon>
  10. </v-btn>
  11. </template>
  12. </v-speed-dial>
  1. <!-- v2.0 -->
  2. <v-speed-dial v-model="fab">
  3. <template v-slot:activator>
  4. <v-btn
  5. dark
  6. fab
  7. >
  8. <v-icon v-if="fab">account_circle</v-icon>
  9. <v-icon v-else>close</v-icon>
  10. </v-btn>
  11. </template>
  12. </v-speed-dial>

v-tabs

  • The color prop is now background-color. Color now affects the default text and slider color
  • Various class names have been changed throughout
    • v-tab__div removed, use v-tab
    • v-tab__itemv-tab
    • v-tabs__sliderv-tabs-slider
    • v-tabs__barv-tabs-bar

v-tabs-items

  • No longer implicitly inherits the v-tabs model when nested. Must have :value or v-model explicitly bound.
  1. <!-- v1.5 -->
  2. <v-tabs v-model="tabs">
  3. ...
  4. <v-tabs-items>
  5. ...
  6. </v-tabs-items>
  7. </vtabs>
  1. <!-- v2.0 -->
  2. <v-tabs v-model="tabs">
  3. ...
  4. <v-tabs-items v-model="tabs">
  5. ...
  6. </v-tabs-items>
  7. </vtabs>

Developer notes: The tabs-items component does not have to be provided and is only necessary for custom implementations.

v-text-field

  • The mask prop and functionality has been removed. Instead you can use 3rd party libraries such as vue-the-mask.

v-text-field, v-select, v-textarea, v-autocomplete, v-combobox

  • The box prop is now filled
  1. <!-- v1.5 -->
  2. <v-text-field box></v-text-field>
  1. <!-- v2.0 -->
  2. <v-text-field filled></v-text-field>

v-text-field, v-select, v-textarea, v-autocomplete, v-combobox, v-btn, v-alert

  • The outline prop is now outlined
  1. <!-- v1.5 -->
  2. <v-btn outline></v-text-field>
  3. <v-autocomplete outline></v-autocomplete>
  4. <v-alert outline></v-alert>
  1. <!-- v2.0 -->
  2. <v-btn outlined></v-text-field>
  3. <v-autocomplete outlined></v-autocomplete>
  4. <v-alert outlined></v-alert>

v-toolbar

  • All existing scrolling techniques and app functionality has been deprecated and moved to v-app-bar

🆘 I need help!

If you are stuck and need help, don’t fret! We have a very large and dedicated community that is able to provide help 24/7. Come to the #release-migration channel.