<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                >[success] # js 簡單粗暴的方式 ~~~ 1.我個人不會建議這種寫法,因為隨著'es6'的崛起class變得不再那么抽象, 'TS'也讓js 有了新的靈魂,但是js依舊還是那個和其他語言不同,奔放自由 仍然是他的特點 2.在 JavaScript 中,我們很多時候都不需要依樣畫瓢地去實現一個模版方法模式,高階函數 是更好的選擇。這也是js的特點 ~~~ >[danger] ##### 案例 ~~~ var Beverage = function( param ){ var boilWater = function(){ console.log( '把水煮沸' ); }; var brew = param.brew || function(){ throw new Error( '必須傳遞 brew 方法' ); }; var pourInCup = param.pourInCup || function(){ throw new Error( '必須傳遞 pourInCup 方法' ); }; var addCondiments = param.addCondiments || function(){ throw new Error( '必須傳遞 addCondiments 方法' ); }; var F = function(){}; F.prototype.init = function(){ boilWater(); brew(); pourInCup(); addCondiments(); }; return F; }; // 傳參調用形成類似繼承效果 var Coffee = Beverage({ brew: function(){ console.log( '用沸水沖泡咖啡' ); }, pourInCup: function(){ console.log( '把咖啡倒進杯子' ); }, addCondiments: function(){ console.log( '加糖和牛奶' ); } }); var Tea = Beverage({ brew: function(){ console.log( '用沸水浸泡茶葉' ); }, pourInCup: function(){ console.log( '把茶倒進杯子' ); }, addCondiments: function(){ console.log( '加檸檬' ); } }); var coffee = new Coffee(); coffee.init(); var tea = new Tea() ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看