你判断的对象根本不一样,怎么用switch?
你这个顶多用三元运算符简写一下...

解决方案 »

  1.   

    看错~
    if(this.speed=="500MHZ")
    {
    the_price+=200;
    }
    else
    {
    the_price+=100;
    }这样改:switch (this.speed)
    {
    case "500MHZ":
    the_price+=200;
    break;
    case "45MHZ":
    //the_price = ...;
    break;
    case "350MHZ":
    //the_price = ....
    break;
    case default:
    break;
    }其它的同理..
      

  2.   

    switch (this.speed)
    {
    case "500MHZ":
    the_price+=200;
    break;
    case "45MHZ":
    //the_price = ...;
    break;
    case "350MHZ":
    //the_price = ....
    break;
    case default:
    break;
    }
      

  3.   

    这样写是不行的,如果行的话怎么能用----挑战----这两个字呢?switch (this.speed)
    {
    case "500MHZ":
    the_price+=200;
    break;
    case "45MHZ":
    //the_price = ...;
    break;
    case "350MHZ":
    //the_price = ....
    break;
    case default:
    break;
    }
    这样写是不行的,如果行的话怎么能用----挑战----这两个字呢?上面那样的我都试过,都不行,
      

  4.   

    eval("switch (this.speed){case \"500MHZ\":the_price+=200;break;case \"45MHZ\":the_price = ;break;case \"350MHZ\":the_price = ;break;default:break;}");
      

  5.   

    this.price=get_price;是不是该写为this.price=get_price();因为前者好像是把get_price函数的引用传给this.price。而后者才是运get_price并把结果返回给this.price
      

  6.   

    谢了,可以用了,
    不过里面的不太理解,像里面的\"500MHZ\" 反斜杆和引号是什么意思,