• <legend id='ZpFhg'><style id='ZpFhg'><dir id='ZpFhg'><q id='ZpFhg'></q></dir></style></legend>

    1. <tfoot id='ZpFhg'></tfoot>

    2. <small id='ZpFhg'></small><noframes id='ZpFhg'>

        <bdo id='ZpFhg'></bdo><ul id='ZpFhg'></ul>
        <i id='ZpFhg'><tr id='ZpFhg'><dt id='ZpFhg'><q id='ZpFhg'><span id='ZpFhg'><b id='ZpFhg'><form id='ZpFhg'><ins id='ZpFhg'></ins><ul id='ZpFhg'></ul><sub id='ZpFhg'></sub></form><legend id='ZpFhg'></legend><bdo id='ZpFhg'><pre id='ZpFhg'><center id='ZpFhg'></center></pre></bdo></b><th id='ZpFhg'></th></span></q></dt></tr></i><div id='ZpFhg'><tfoot id='ZpFhg'></tfoot><dl id='ZpFhg'><fieldset id='ZpFhg'></fieldset></dl></div>

        多个 if 语句的替代方案

        时间:2023-10-01

              <small id='5TwPo'></small><noframes id='5TwPo'>

                <tbody id='5TwPo'></tbody>
                <bdo id='5TwPo'></bdo><ul id='5TwPo'></ul>
                  <legend id='5TwPo'><style id='5TwPo'><dir id='5TwPo'><q id='5TwPo'></q></dir></style></legend>
                1. <i id='5TwPo'><tr id='5TwPo'><dt id='5TwPo'><q id='5TwPo'><span id='5TwPo'><b id='5TwPo'><form id='5TwPo'><ins id='5TwPo'></ins><ul id='5TwPo'></ul><sub id='5TwPo'></sub></form><legend id='5TwPo'></legend><bdo id='5TwPo'><pre id='5TwPo'><center id='5TwPo'></center></pre></bdo></b><th id='5TwPo'></th></span></q></dt></tr></i><div id='5TwPo'><tfoot id='5TwPo'></tfoot><dl id='5TwPo'><fieldset id='5TwPo'></fieldset></dl></div>

                2. <tfoot id='5TwPo'></tfoot>
                3. 本文介绍了多个 if 语句的替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的代码包含很多多个 if 语句.有没有其他方法可以摆脱这些陈述.例如假设我有以下条件

                  My code contains a lot of multiple if statements. Is there any other way to get rid of these statements. For example suppose I have the following conditions

                  if(t1 >= 1 && t2 == 0 && t3 == 0) $('div.b_class').fadeIn();
                  if(t1 == 0 && t2 >= 1 && t3 == 0) $('div.c_class').fadeIn();
                  if(t1 == 0 && t2 == 0 && t3 == 1) $('div.d_class').fadeIn();
                  if(t1 && t2 >= 1 && t3 == 0) $('div.b_class.c_class').fadeIn();
                  if(t1 && t3 >= 1&& t2 == 0) $('div.b_class.d_class').fadeIn();
                  

                  有什么方法可以简化这些语句?

                  Is there any way to simplify these statements?

                  推荐答案

                  你可以像这样使用带有条件的 switch case 结构:

                  You could use a switch case structure with conditions inside like this :

                  switch(true)
                  {
                   case (t1 >= 1 && t2 == 0 && t3 == 0) : $('div.b_class').fadeIn(); break;
                   case (t1 == 0 && t2 >= 1 && t3 == 0) : $('div.c_class').fadeIn(); break;
                   case (t1 == 0 && t2 == 0 && t3 == 1) : $('div.d_class').fadeIn(); break;
                   case (t1 && t2 >= 1 && t3 == 0)      : $('div.b_class.c_class').fadeIn(); break;
                   case (t1 && t3 >= 1&& t2 == 0)       : $('div.b_class.d_class').fadeIn(); break;
                  }
                  

                  这篇关于多个 if 语句的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:仅适用于 Internet Explorer 10 的条件 CSS 下一篇:条件 CSS 区分 IE6 到 IE7

                  相关文章

                  <i id='50rr4'><tr id='50rr4'><dt id='50rr4'><q id='50rr4'><span id='50rr4'><b id='50rr4'><form id='50rr4'><ins id='50rr4'></ins><ul id='50rr4'></ul><sub id='50rr4'></sub></form><legend id='50rr4'></legend><bdo id='50rr4'><pre id='50rr4'><center id='50rr4'></center></pre></bdo></b><th id='50rr4'></th></span></q></dt></tr></i><div id='50rr4'><tfoot id='50rr4'></tfoot><dl id='50rr4'><fieldset id='50rr4'></fieldset></dl></div>

                    <legend id='50rr4'><style id='50rr4'><dir id='50rr4'><q id='50rr4'></q></dir></style></legend>
                      <bdo id='50rr4'></bdo><ul id='50rr4'></ul>
                    1. <small id='50rr4'></small><noframes id='50rr4'>

                      <tfoot id='50rr4'></tfoot>