vue-component-register
Version:
Allow components to register their subComponents.
7 lines (6 loc) • 1.02 kB
JavaScript
/*!
* vue-component-register v1.1.0
* (c) 2018-present fjc0k <fjc0kb@gmail.com> (https://github.com/fjc0k)
* Released under the MIT License.
*/
!function(n,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):n.VueComponentRegister=o()}(this,function(){"use strict";var n=function n(o,e,t){void 0===t&&(t=[]);var i=e.subComponents;return i&&"object"==typeof i&&Object.keys(i).forEach(function(e){var f=""+o+e,u=i[e];t.push([f,u]),n(f,u,t)}),t},o={install:function(o){var e=o.component;o.component=function(){return arguments[1]&&n(arguments[0],arguments[1]).forEach(function(n){var t=n[0],i=n[1];e.apply(o,[t,i])}),e.apply(o,arguments)},o.mixin({beforeCreate:function(){var o,e,t=this.$options;t.components&&(o=t.components,void 0===e&&(e=[]),Object.keys(o).forEach(function(t){var i=o[t];e.push([t,i]),n(t,i,e)}),e).forEach(function(n){var o=n[0],e=n[1];t.components[o]=e})}})}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(o),o});