js设计模式:建造者模式

作用:

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

这个是很常见的设计模式

示例:

javascript 复制代码
        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 = render
            this.$mount = $mount
            this.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')
相关推荐
摘星编程6 小时前
React Native for OpenHarmony 实战:Linking 链接处理详解
javascript·react native·react.js
胖者是谁7 小时前
EasyPlayerPro的使用方法
前端·javascript·css
EndingCoder7 小时前
索引类型和 keyof 操作符
linux·运维·前端·javascript·ubuntu·typescript
摘星编程8 小时前
React Native for OpenHarmony 实战:ImageBackground 背景图片详解
javascript·react native·react.js
摘星编程9 小时前
React Native for OpenHarmony 实战:Alert 警告提示详解
javascript·react native·react.js
Joe5569 小时前
vue2 + antDesign 下拉框限制只能选择2个
服务器·前端·javascript
WHS-_-20229 小时前
Tx and Rx IQ Imbalance Compensation for JCAS in 5G NR
javascript·算法·5g
摘星编程9 小时前
React Native for OpenHarmony 实战:GestureResponderSystem 手势系统详解
javascript·react native·react.js
lili-felicity9 小时前
React Native for OpenHarmony 实战:加载效果的实现详解
javascript·react native·react.js·harmonyos
济61710 小时前
linux 系统移植(第六期)--Uboot移植(5)--bootcmd 和 bootargs 环境变量-- Ubuntu20.04
java·前端·javascript