javascript与php注册自己的“事件”

  1. JAVASCRIPT:
    a. 代码:
    var a = function(){
    this.eve
    this.func
    this.on = function(eve,func){
        this.eve = eve
        this.func = func
    }
    this.emit = function(eve){
        if(this.eve == eve){
            var func = this.func
            func()
        }
    }
    }
    var aa = new a()
    aa.on('click',function(){
    console.log('im click')
    })
    aa.emit('click')

    b. 输出:

    平湖网站建设公司创新互联建站,平湖网站设计制作,有大型网站制作公司丰富经验。已为平湖上1000+提供企业网站建设服务。企业网站搭建\外贸网站建设要多少钱,请找那个售后服务好的平湖做网站的公司定做!

    im click
  2. PHP:
    a. 代码:
    eve = $eve;
        $this->func = $func;
    }
    public function emit($eve){
        if($this.eve == $eve){
            $func = $this->func;
            $func();
        }
    }
    }
    $a = new a();
    $a->on('click',function(){
    echo "im click";
    });
    $a->emit('click');

    b. 输出:

    im click

当前文章:javascript与php注册自己的“事件”
当前路径:http://pwwzsj.com/article/peciis.html