js设计模式:建造者模式

作用:

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

这个是很常见的设计模式

示例:

        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')

相关推荐

  1. 设计模式——建造模式

    2024-02-22 07:26:02       63 阅读
  2. 设计模式-建造模式

    2024-02-22 07:26:02       55 阅读
  3. 设计模式-建造模式

    2024-02-22 07:26:02       48 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-22 07:26:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-22 07:26:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-02-22 07:26:02       87 阅读
  4. Python语言-面向对象

    2024-02-22 07:26:02       96 阅读

热门阅读

  1. Oracle误删除数据文件恢复---惜分飞

    2024-02-22 07:26:02       49 阅读
  2. 《黑客帝国》让你穿越虚拟世界

    2024-02-22 07:26:02       49 阅读
  3. history of philosophy, i guess (history of all ideas)

    2024-02-22 07:26:02       56 阅读
  4. 自动化开展思路

    2024-02-22 07:26:02       55 阅读
  5. 今日分享个有点瑕疵的自动轮播图

    2024-02-22 07:26:02       45 阅读
  6. IDEA基础快捷键

    2024-02-22 07:26:02       49 阅读
  7. Vue练习5:图片的引入

    2024-02-22 07:26:02       45 阅读
  8. uniapp微信公众号H5分享

    2024-02-22 07:26:02       47 阅读
  9. 【算法】复杂度分析

    2024-02-22 07:26:02       47 阅读
  10. vue中nextTick使用以及原理

    2024-02-22 07:26:02       52 阅读
  11. 关于/proc/fs/lustre

    2024-02-22 07:26:02       45 阅读