New
-
When used on a component,
v-on
can use the.native
modifier to listen to native DOM events instead of component events:<my-comp @click.native="onClick"></my-comp>
When using render functions, native event handlers need to be nested under
nativeOn
instead ofon
in vnode data:render (h) { return h('my-comp', { nativeOn: { click: () => { ... }}}) }
-
v-bind
can now be used to bind to DOM properties instead of attributes with the.prop
modifier:<div :text-content.prop="text"></div>
The modifier also works for object
v-bind
, which will probably be more readable:<div v-bind.prop="{ textContent: text }"></div>
-
Functional components can now also accept slots. However, the slots are lazy evaluated - they are only resolved when you call the
context.slots()
function:Vue.component('example', { functional: true, render (h, ctx) { const slots = ctx.slots() slots.default // <-- access slot content like vm.$slots } })
Breaking Changes
-
Vnode data format change: now uses the
domProps
nested object for binding to DOM properties (instead ofprops
):render (h) { h('div', { domProps: { innerHTML: '...' }}) }
The
props
object is now only used for binding component props. -
User watchers created via
vm.$watch
are now fired before component re-renders. This gives the user a chance to further update other state before the component re-render, thus avoiding unnecessary updates. For example, you can watch a component prop and update the component's own data when the prop changes.To do something with the DOM after component updates, just use the
updated
lifecycle hook.
Fixed
- Fixed some edge cases in
<transition-group>
move animations. - Fixed non-functional transition wrapper components not updating properly.
- Fixed client-side hydration failed check for elements with
v-html
/v-text
. - #3296 incorrect unknown element warning