作用:

将众多功能独立封装,然后用一个大类将其全部收纳,形成一个完整的功能

这个是很常见的设计模式

示例:

function render(h){}function h(){}function $mount(dom){ console.log(dom,'绑定的根节点') console.log(this,'this是vue实例')}function use(plugin){}function $attr(){}function $emit(){}class Vue{ constructor(vue){this.render = renderthis.$mount = $mountthis.use = use } attr = $attr $emit = $emit static self = function(){return '看不到我' }}//使用let vueComponent1 =new Vue({beforeCreate(){},created(){},render:h=>h()})console.log(vueComponent1,'vue组件实例')vueComponent1.$mount('#app')