wangqilangfff 2022-04-22 17:31 采纳率: 80%
浏览 113
已结题

原型对象创建方法案例 javascript 具体实现步骤

#我的代码

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <p id="111"></p>
        <p id="222"></p>
        <p id="333"></p>
        <script>
            function Clothes(aaa, bbb) {
                this.aaa = aaa;
                this.bbb = bbb;
            }
            Clothes.prototype.Clothes_fun = function() {
                return this.aaa + "是" + this.bbb
            };
            var clothes1 = new Clothes("黑色的连衣裙", "小丽穿的衣服");
            var clothes2 = new Clothes("黄色的吊带裙", "小美穿的衣服");

            document.getElementById("111").innerHTML = clothes1.Clothes_fun();
            document.getElementById("222").innerHTML = clothes2.Clothes_fun();
            Clothes.prototype = {
                Clothes_fun: function() {
                    return this.bbb + "是" + this.aaa
                }
            }
            var clothes1 = new Clothes("黑色的连衣裙", "小丽穿的衣服");
            document.getElementById("333").innerHTML = clothes1.Clothes_fun();
        </script>
    </body>
    <html>

问原型属性怎么添加

img

  • 写回答

1条回答 默认 最新

  • 溪风沐雪 2022-04-22 18:12
    关注
    
    添加属性:Clothes.prototype.type = 'xxxxxx'
    添加方法:Clothes.prototype.Clothes_fun = functio(){
      xxxxxx
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 4月28日
  • 已采纳回答 4月28日
  • 修改了问题 4月22日
  • 创建了问题 4月22日

悬赏问题

  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真