vue-merge-data
Intelligently merge data for Vue render functions.
yarn add vue-merge-data
CDN: jsDelivr | UNPKG (Avaliable as window.VueMergeData
)
Usage
First, import it:
Then, use it in Vue render functions:
// Normal component name: 'primary-button' props: mini: Boolean { return } // Functional component name: 'primary-button' functional: true props: mini: Boolean { return }
Merging strategies
Prop(s) | Strategy | Example |
---|---|---|
staticClass | append | target: { staticClass: 'button' } source: { staticClass: 'button--mini' } result: { staticClass: 'button button--mini' } |
attrs, domProps, scopedSlots, staticStyle, props, hook, transition | override | target: { attrs: { type: 'reset' } } source: { attrs: { type: 'submit' } } result: { attrs: { type: 'submit' } } |
class, style, directives, on, nativeOn | expand | target: { class: 'button', on: { click: FN1 } } source: { class: { mini: true }, on: { click: FN2 } } result: { class: ['button', { mini: true }], on: { click: [FN2, FN1] } } |
others: slot, key... | override | target: { slot: 'icon' } source: { slot: 'image' } result: { slot: 'image' } |