标题:prototype继承,,显示不出来呀
取消只看楼主
渐渐鱼
Rank: 1
等 级:新手上路
帖 子:80
专家分:0
注 册:2018-5-11
结帖率:90%
 问题点数:0 回复次数:0 
prototype继承,,显示不出来呀
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
    </head>
    <body>
        <script>
        function Car()        //基类
        {
            this.color="white";
            this.size="middle";
            this.set=function set(color,size){this.color=color;this.size=size;}
            this.run=function(){return "I can run";}
            this.voice=function() {return "I can voice";}
        }
        function Bus()     //子类
        {
            Bus.prototype=new Car();
            Bus.prototype.constructor=Bus;
             this.kkk=function kkk(){return "KKK";}
        }
        function Truck()
        {
            Truck.prototype=new Truck();
            Truck.prototype.constructor=Truck;
            this.kkk=function kkk(){return "kkk";}
        }
        var bus=new Bus();
        bus.set("white","middle");
        alert(bus.color);
        alert(bus.run());
        var truck=new Truck();
        truck.set("grey","big");
        alert(truck.size);
        alert(truck.voice());
        </script>
    </body>
    </html>
搜索更多相关主题的帖子: prototype function this color size 
2018-06-24 17:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-488116-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.049997 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved