在JavaScript中包含条件在关系php常数中



我知道如何在JS中包含条件。就像您在我的桌子上看到的那样,我这个常数mode_b2b_b2c;如何在JS中做同一件事。

tk。

         <table width="100%" cellpadding="5" cellspacing="0" border="0">
           <tr>
        if (MODE_B2B_B2C == 'true') {
          $content .= '
                          <td>' . $this->app->getDef('table_heading_customers_group') . '</td>
                      ';
        }
</tr>
</table>
      $output = <<<EOD
<script type="text/javascript"><!--
  var quantitydiscount_row = $i;
  function addQuantityDiscountValue() {

   //customers_group_id
    html += '<td>';
    html += '  <select name="products_quantitydiscount[' + quantitydiscount_row + '][customers_group_id]" class="form-control">{$customers_group_name}</select>';
    html += '</td>';

    quantitydiscount_row++;
  }
</script>
<br />
EOD;

您可以使用模板字符串:

let myVal = 123;
function condition(input) {
  if (input > 10) return "foo";
  return "bar";
}
let str = `This will output ${myVal} * 2 = ${myVal * 2}. 
Condition: ${condition(2)}
Condition: ${condition(20)}
`;
console.log(str);

最新更新