第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

nodejs 如何實現(xiàn) php 的 __callStatic 魔術方法 ?

nodejs 如何實現(xiàn) php 的 __callStatic 魔術方法 ?

牛魔王的故事 2019-02-14 22:19:57
nodejs 如何實現(xiàn) php 的 __callStatic 魔術方法 ?或者說, 如何 如何使用 nodejs 實現(xiàn) static 對 普通方法的呼叫 ?
查看完整描述

1 回答

?
郎朗坤

TA貢獻1921條經(jīng)驗 獲得超9個贊

可以嘗試用Prixy來實現(xiàn),但是需要調用代理后的對象而不是原類

(()=>{

    class Test{

        static staticMethod(){

            console.log(`this is staticMethod`);

        }

    }


    class Test2 extends Test{

        static staticMethod2(){

            console.log(`this is staticMethod2`);

        }

    }


    var P = new Proxy(Test, {

        apply: (target, that, args) => {

            console.log("apply", target, that, args);

        },

        get: (target, property, receiver) => {

            if(property in target){

                return target[property];

            }else{

                return Test2.staticMethod2;

            }

        }

    });

    P.staticMethod();

    P.staticMethod2();

})();


查看完整回答
反對 回復 2019-02-26
  • 1 回答
  • 0 關注
  • 587 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號