[英]Include condition inside javascript in relation php constant
我會知道如何在js中包含條件。 就像您在我的表格中看到的那樣,此常量MODE_B2B_B2C; 如何在js中做同樣的事情。
k
<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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.