1234567891011121314151617181920212223242526272829303132333435363738 |
- global.installComponents = function (component, components) {
- var options = typeof component.exports === 'function'
- ? component.exports.extendOptions
- : component.options
- if (typeof component.exports === 'function') {
- options.components = component.exports.options.components
- }
- options.components = options.components || {}
- for (var i in components) {
- options.components[i] = options.components[i] || components[i]
- }
- if (options.functional) {
- provideFunctionalComponents(component, options.components)
- }
- }
- var functionalPatchKey = '_functionalComponents'
- function provideFunctionalComponents(component, components) {
- if (component.exports[functionalPatchKey]) {
- return
- }
- component.exports[functionalPatchKey] = true
- var render = component.exports.render
- component.exports.render = function (h, vm) {
- return render(h, Object.assign({}, vm, {
- _c: function (n, a, b) {
- return vm._c(components[n] || n, a, b)
- }
- }))
- }
- }
|