JavaScript Boolean(逻辑)对象

本文详细介绍了Boolean对象在JavaScript中的应用,如何通过new Boolean()创建逻辑对象,并阐述了不同参数下对象值的判断机制。

Boolean(逻辑)对象用于将非逻辑值转换为逻辑值(true 或者 false)。

Boolean 对象

您可以将 Boolean 对象理解为一个产生逻辑值的对象包装器。

Boolean(逻辑)对象用于将非逻辑值转换为逻辑值(true 或者 false)。

创建 Boolean 对象

使用关键词 new 来定义 Boolean 对象。下面的代码定义了一个名为 myBoolean 的逻辑对象:


var myBoolean=new Boolean()

注释:如果逻辑对象无初始值或者其值为 0、-0、null、""、false、undefined 或者 NaN,那么对象的值为 false。否则,其值为 true(即使当自变量为字符串 "false" 时)!

下面的所有的代码行均会创建初始值为 false 的 Boolean 对象。


var myBoolean=new Boolean();
var myBoolean=new Boolean(0);
var myBoolean=new Boolean(null);
var myBoolean=new Boolean("");
var myBoolean=new Boolean(false);
var myBoolean=new Boolean(NaN);

下面的所有的代码行均会创初始值为 true 的 Boolean 对象:


var myBoolean=new Boolean(1);
var myBoolean=new Boolean(true);
var myBoolean=new Boolean("true");
var myBoolean=new Boolean("false");
var myBoolean=new Boolean("Bill Gates");
我要点击之后跳转到新的比对界面,请修改,比对界面如下,请用AntDesignVue新框架实现:<#import “/decorators/includes/macros.ftl” as m> <#assign ww = JspTaglibs[“/WEB-INF/webwork.tld”] /> <#include “/template/includes/actionerrors.ftl”> <style type="text/css"> <!-- .STYLE1 {color: #808000} .STYLE2 {color: #408080} --> </style> <div class="app"> <h3 class="center">e-RunCard and MES Compared Result</h3> <table border="0" cellspacing="1" cellpadding="8" width="80%" align="center"> <tr> <th><span class="STYLE2"> </span></th> <th><span class="STYLE2"> </span></th> <th colspan="4" class="center">e-RC</th> <th colspan="3" class="center"><span class="STYLE1">MES</span></th> </tr> <tr> <th><span class="STYLE2">Cond.</span></th> <th><span class="STYLE2">StepNo</span></th> <th>Recipe</th> <th>EQP</th> <th>Reticle</th> <th>Qty</th> <th><span class="STYLE1">Recipe</span></th> <th><span class="STYLE1">EQP</span></th> <th><span class="STYLE1">Reticle</span></th> </tr> <#if requestForm.stepForms?has_content> <#list requestForm.stepForms as stepForms> <tr class="b"> <td><span class="STYLE2">${stepForms.stepSerialNo?if_exists}</span></td> <td><span class="STYLE2">${stepForms.stepNo?if_exists}</span></td> <#if stepForms.area == "PHOTO" || stepForms.area=="S1A-PHOTO" || stepForms.area=="S1B-PHOTO" || stepForms.area=="S1C-PHOTO" || stepForms.area=="M1A-PHOTO" || stepForms.area=="M1B-PHOTO" || stepForms.area=="M1C-PHOTO"|| stepForms.area=="SXA-PHOTO" || stepForms.area=="SXC-PHOTO"> <td>${stepForms.trackOutRecipe?if_exists}@${stepForms.scannerRecipe?if_exists}</td> <#else> <td>${stepForms.recipe?if_exists}</td> </#if> <td>${stepForms.eqpModeName?if_exists}</td> <#if stepForms.area == "PHOTO" || stepForms.area=="S1A-PHOTO" || stepForms.area=="S1B-PHOTO" || stepForms.area=="S1C-PHOTO" || stepForms.area=="M1A-PHOTO" || stepForms.area=="M1B-PHOTO" || stepForms.area=="M1C-PHOTO"|| stepForms.area=="SXA-PHOTO" || stepForms.area=="SXC-PHOTO"> <td>${stepForms.reticleId?if_exists}</td> <#else> <td></td> </#if> <td>${stepForms.waferIdQty?if_exists}</td> <td><span class="STYLE2"><#if stepForms.stepNo?exists><#if stepForms.stepNo?trim!="">${requestForm.compareInfos[stepForms.stepNo].mesRecipe?if_exists}</#if></#if></span></td> <td><span class="STYLE2"><#if stepForms.stepNo?exists><#if stepForms.stepNo?trim!="">${requestForm.compareInfos[stepForms.stepNo].EQPGroup?if_exists}</#if></#if></span></td> <td><span class="STYLE2"><#if stepForms.stepNo?exists><#if stepForms.stepNo?trim!="">${requestForm.compareInfos[stepForms.stepNo].reticleId?if_exists}</#if></#if></span></td> </tr> </#list> </#if> </table> <br> <table border="0" cellspacing="1" cellpadding="8" width="80%" align="center"> <tr> <th colspan="3" class="center">Step No</th> <th colspan="3" class="center">e-RC Qty</th> <th colspan="3" class="center">MES Qty</th> </tr> <#if requestForm.ercAllStep?has_content> <#list requestForm.ercAllStep as eachNo> <tr class="b"> <td colspan="3" class="center">${eachNo?if_exists}</td> <td colspan="3" class="center"><#if eachNo?exists&&eachNo?trim!="">${requestForm.compareInfos[eachNo].ercQty}</#if></td> <td colspan="3" class="center"><#if eachNo?exists&&eachNo?trim!="">${requestForm.compareInfos[eachNo].mesQty}</#if></td> </tr> </#list> </#if> </table> <br> <table border="0" cellspacing="1" cellpadding="8" width="80%" align="center"> <tr> <th colspan="4">MES All Step No</th> </tr> <tr class="b"> <#--td colspan="4"> <#list requestForm.mesAllStep as eachNo>${eachNo?default("")} </#list--> <td> ${requestForm.holdStepNo?if_exists}-->${requestForm.ercStepNo?if_exists} </td> </tr> </table> <br> <table border="0" cellspacing="1" cellpadding="8" width="80%" align="center"> <tr> <th colspan="4">Check Result</th> </tr> <#if requestForm.stepForms?has_content> <#list requestForm.stepForms as stepForms> <#if stepForms.area == "PHOTO" || stepForms.area=="S1A-PHOTO" || stepForms.area=="S1B-PHOTO" || stepForms.area=="S1C-PHOTO" || stepForms.area=="M1A-PHOTO" || stepForms.area=="M1B-PHOTO" || stepForms.area=="M1C-PHOTO"|| stepForms.area=="SXA-PHOTO" || stepForms.area=="SXC-PHOTO"> <#if stepForms.stepNo?exists&&stepForms.stepNo?trim!=""><#if (stepForms.trackOutRecipe)?default("")?trim + "@" + (stepForms.scannerRecipe?default(""))?trim != (requestForm.compareInfos[stepForms.stepNo].mesRecipe?default(""))?trim> <tr class="b"> <td colspan="4">****************************************************************************************</td> </tr> <tr class="b"> <td colspan="4"><font color="red"><b>Condition   ${stepForms.stepSerialNo?if_exists} (Recipe : e-RC = ${stepForms.trackOutRecipe?if_exists}@${stepForms.scannerRecipe?if_exists},  MES  =  ${ requestForm.compareInfos[stepForms.stepNo].mesRecipe?default("")} no match.)</b></font></td> </tr> </#if> </#if> <#else> <#if stepForms.stepNo?exists&&stepForms.stepNo?trim!=""><#if stepForms.recipe?default("")?trim != requestForm.compareInfos[stepForms.stepNo].mesRecipe?default("")?trim> <tr class="b"> <td colspan="4">****************************************************************************************</td> </tr> <tr class="b"> <td colspan="4"><font color="red"><b>Condition   ${stepForms.stepSerialNo?if_exists} (Recipe : e-RC = ${stepForms.recipe?if_exists},  MES  =  ${requestForm.compareInfos[stepForms.stepNo].mesRecipe?default("")} no match.)</b></font></td> </tr> </#if> </#if> </#if> </#list> </#if> <#if requestForm.stepForms?has_content> <#assign i=0> <#list requestForm.stepForms as stepForms> <#assign i=stepForms_index> <#if stepForms.stepNo?exists&&stepForms.stepNo?trim!=“”><#if stepForms.eqpModeName?trim != requestForm.compareInfos[stepForms.stepNo].EQPGroup?trim?if_exists> <tr class="b"> <td colspan="4">****************************************************************************************</td> </tr> <tr class="b"> <td colspan="4"><font color="red"><b>Condition   ${stepForms.stepSerialNo?if_exists} (Eqp : e-RC = ${stepForms.eqpModeName?if_exists},  MES  =  ${requestForm.compareInfos[stepForms.stepNo].EQPGroup?default("")} no match.)</b></font></td> </tr> </#if> </#if> </#list> </#if> <tr class="b"> <td colspan="4">****************************************************************************************</td> </tr> <#if requestForm.stepForms?has_content> <#assign i=0> <#list requestForm.stepForms as stepForms> <#assign i=stepForms_index> <#if stepForms.area == “PHOTO” || stepForms.area==“S1A-PHOTO” || stepForms.area==“S1B-PHOTO” || stepForms.area==“S1C-PHOTO” || stepForms.area==“M1A-PHOTO” || stepForms.area==“M1B-PHOTO” || stepForms.area==“M1C-PHOTO” || stepForms.area==“SXA-PHOTO” || stepForms.area==“SXC-PHOTO”> <#if stepForms.stepNo?exists&&stepForms.stepNo?trim!=“”><#if stepForms.reticleId?exists && stepForms.reticleId?trim != requestForm.compareInfos[stepForms.stepNo].reticleId?default(“”)?trim> <tr class="b"> <td colspan="4">****************************************************************************************</td> </tr> <tr class="b"> <td colspan="4"><font color="red"><b>Condition   ${stepForms.stepSerialNo?if_exists} (Reticle : e-RC = ${stepForms.reticleId?if_exists},  MES  =  ${requestForm.compareInfos[stepForms.stepNo].reticleId?default("")} no match.)</b></font></td> </tr> </#if> </#if> </#if> </#list> </#if> <tr class="b"> <td colspan="4">****************************************************************************************</td> </tr> <tr class="b"> <td colspan="4">=============================================================================</td> </tr> <#if requestForm.ercAllStep?has_content> <#list requestForm.ercAllStep as stepNo> <#if stepNo?exists && stepNo?trim!=""><#if requestForm.compareInfos[stepNo].mesQty != requestForm.compareInfos[stepNo].ercQty> <tr class="b"> <td colspan="4"> <font color="red"><b>Step No:  ${stepNo} (QTY: e-RC=${requestForm.compareInfos[stepNo].ercQty?default("")},MES=${requestForm.compareInfos[stepNo].mesQty?default("")} no match.)</b></font> </td> </tr> </#if> </#if> </#list> </#if> <tr class="b"> <td colspan="4">=============================================================================</td> </tr> <#if requestForm.mesStepLength?exists> <#if requestForm.ercAllStep?has_content> <#assign ercLenght=requestForm.ercStepLength> <#assign mesLenght=requestForm.mesStepLength> <#if ercLenght!=mesLenght> <tr class="b"> <td colspan="4"><font color="red"><b>Step No counts  : ( e-RC  =  ${ercLenght}, MES = ${mesLenght} no match.)</b></font></td> </tr> </#if> </#if> </#if> </table> <table width="80%"> <tr> <td class="center"> <#if requestForm.status="DRAFT"> <input type="button" class="btn" value="Back" onclick="window.document.location.href='updateRequestForm.action?requestFormId=${requestForm.id}'"/> <#else> <input type="button" class="btn" value="Back" onclick="javascript:history.go(-1)"/> </#if> </td> </tr> </table> <div>
12-06
修改代码如下后:<template> <a-card style="margin-top: 20px" title="Applicant Information"> <!-- 标题 --> <h3>e-RunCard and MES Compared Result</h3> <!-- 表格1: Step-by-Step 对比 (Recipe, EQP, Reticle, Qty) --> <table class="compare-table" border="0" cellspacing="1" cellpadding="8" width="90%" align="center"> <thead> <tr> <th> </th> <th> </th> <th colspan="4" class="center">e-RC</th> <th colspan="3" class="center mes-header">MES</th> </tr> <tr> <th>Cond.</th> <th>StepNo</th> <th>Recipe</th> <th>EQP</th> <th>Reticle</th> <th>Qty</th> <th class="mes-header">Recipe</th> <th class="mes-header">EQP</th> <th class="mes-header">Reticle</th> </tr> </thead> <tbody> <tr v-for="sf in stepForms" :key="sf.stepNo" class="b"> <td>{{ sf.stepSerialNo }}</td> <td>{{ sf.stepNo }}</td> <!-- RC Recipe --> <td> <span v-if="isPhotoArea(sf.area)"> {{ [sf.trackOutRecipe, sf.scannerRecipe].filter(Boolean).join('@') }} </span> <span v-else>{{ sf.recipe || '' }}</span> </td> <!-- RC EQP --> <td>{{ sf.eqpModeName || '' }}</td> <!-- RC Reticle --> <td> <span v-if="isPhotoArea(sf.area)">{{ sf.reticleId || '' }}</span> <span v-else></span> </td> <!-- RC Qty --> <td>{{ sf.waferIdQtyQty || '' }}</td> <!-- MES Recipe --> <td class="mes-cell"> {{ compareInfos[sf.stepNo]?.mesRecipe || '' }} </td> <!-- MES EQP --> <td class="mes-cell"> {{ compareInfos[sf.stepNo]?.EQPGroup || '' }} </td> <!-- MES Reticle --> <td class="mes-cell"> {{ compareInfos[sf.stepNo]?.reticleId || '' }} </td> </tr> </tbody> </table> <br /> <!-- 表格2: 数量对比 --> <table class="compare-table" border="0" cellspacing="1" cellpadding="8" width="80%" align="center"> <thead> <tr> <th colspan="3" class="center">Step No</th> <th colspan="3" class="center">e-RC Qty</th> <th colspan="3" class="center">MES Qty</th> </tr> </thead> <tbody> <tr v-for="stepNo in ercAllStep" :key="'qty-' + stepNo" class="b"> <td colspan="3" class="center">{{ stepNo }}</td> <td colspan="3" class="center">{{ compareInfos[stepNo]?.ercQty || 0 }}</td> <td colspan="3" class="center">{{ compareInfos[stepNo]?.mesQty || 0 }}</td> </tr> </tbody> </table> <br /> <!-- 表格3: MES All Step Range --> <table class="compare-table" border="0" cellspacing="1" cellpadding="8" width="80%" align="center"> <thead> <tr> <th colspan="4">MES All Step No</th> </tr> </thead> <tbody> <tr class="b"> <td>{{ holdStepNo }} --> {{ ercStepNo }}</td> </tr> </tbody> </table> <br /> <!-- 表格4: Check Result 差异汇总 --> <table class="compare-table" border="0" cellspacing="1" cellpadding="8" width="80%" align="center"> <thead> <tr> <th colspan="4">Check Result</th> </tr> </thead> <tbody> <!-- Recipe 不匹配(Photo Area) --> <template v-for="sf in stepForms" > <template v-if="isPhotoArea(sf.area) && sf.stepNo && sf.stepNo.trim()"> <template v-if=" [sf.trackOutRecipe, sf.scannerRecipe].filter(Boolean).join('@').trim() !== (compareInfos[sf.stepNo]?.mesRecipe || '').trim() "> <tr class="separator"> <td colspan="4">****************************************************************************************</td> </tr> <tr class="b error-row"> <td colspan="4"> <span style="color: red; font-weight: bold;"> Condition   {{ sf.stepSerialNo }}  (Recipe : e-RC = {{ [sf.trackOutRecipe, sf.scannerRecipe].filter(Boolean).join('@') }},   MES  =  {{ compareInfos[sf.stepNo]?.mesRecipe || 'N/A' }} no match.) </span> </td> </tr> </template> </template> </template> <!-- Recipe 不匹配(非 Photo Area) --> <template v-for="sf in stepForms" > <template v-if="!isPhotoArea(sf.area) && sf.stepNo && sf.stepNo.trim()"> <template v-if=" (sf.recipe || '').trim() !== (compareInfos[sf.stepNo]?.mesRecipe || '').trim() "> <tr class="separator"> <td colspan="4">****************************************************************************************</td> </tr> <tr class="b error-row"> <td colspan="4"> <span style="color: red; font-weight: bold;"> Condition   {{ sf.stepSerialNo }}  (Recipe : e-RC = {{ sf.recipe || 'N/A' }},   MES  =  {{ compareInfos[sf.stepNo]?.mesRecipe || 'N/A' }} no match.) </span> </td> </tr> </template> </template> </template> <!-- EQP 不匹配 --> <template v-for="sf in stepForms" > <template v-if="sf.stepNo && sf.stepNo.trim()"> <template v-if=" (sf.eqpModeName || '').trim() !== (compareInfos[sf.stepNo]?.EQPGroup || '').trim() "> <tr class="separator"> <td colspan="4">****************************************************************************************</td> </tr> <tr class="b error-row"> <td colspan="4"> <span style="color: red; font-weight: bold;"> Condition   {{ sf.stepSerialNo }}  (Eqp : e-RC = {{ sf.eqpModeName || 'N/A' }},   MES  =  {{ compareInfos[sf.stepNo]?.EQPGroup || 'N/A' }} no match.) </span> </td> </tr> </template> </template> </template> <!-- Reticle 不匹配 --> <template v-for="sf in stepForms" > <template v-if="isPhotoArea(sf.area) && sf.stepNo && sf.stepNo.trim()"> <template v-if=" (sf.reticleId || '').trim() !== (compareInfos[sf.stepNo]?.reticleId || '').trim() "> <tr class="separator"> <td colspan="4">****************************************************************************************</td> </tr> <tr class="b error-row"> <td colspan="4"> <span style="color: red; font-weight: bold;"> Condition   {{ sf.stepSerialNo }}  (Reticle : e-RC = {{ sf.reticleId || 'N/A' }},   MES  =  {{ compareInfos[sf.stepNo]?.reticleId || 'N/A' }} no match.) </span> </td> </tr> </template> </template> </template> <!-- 分隔线 --> <tr class="separator"><td colspan="4">****************************************************************************************</td></tr> <tr class="separator"><td colspan="4">=============================================================================</td></tr> <!-- Qty 不匹配 --> <template v-for="stepNo in ercAllStep" > <template v-if="stepNo && stepNo.trim()"> <template v-if=" Number(compareInfos[stepNo]?.ercQty) !== Number(compareInfos[stepNo]?.mesQty) "> <tr class="b error-row"> <td colspan="4"> <span style="color: red; font-weight: bold;"> Step No:  {{ stepNo }} (QTY: e-RC={{ compareInfos[stepNo]?.ercQty || 0 }}, MES={{ compareInfos[stepNo]?.mesQty || 0 }} no match.) </span> </td> </tr> </template> </template> </template> <tr class="separator"><td colspan="4">=============================================================================</td></tr> <!-- Step Count 不一致 --> <template v-if="ercStepLength !== mesStepLength"> <tr class="b error-row"> <td colspan="4"> <span style="color: red; font-weight: bold;"> Step No counts : ( e-RC  =  {{ ercStepLength }}, MES = {{ mesStepLength }} no match.) </span> </td> </tr> </template> </tbody> </table> <!-- 返回按钮 --> <div style="text-align: center; margin-top: 30px;"> <a-button type="primary" @click="$router.go(-1)">Back</a-button> </div> </a-card> </template> <script> export default { name: 'CompareResultPage', data() { return { caseNo: '', stepForms: [], compareInfos: {}, ercAllStep: [], mesAllStep: [], holdStepNo: '', ercStepNo: '', ercStepLength: 0, mesStepLength: 0 }; }, async created() { this.caseNo = this.$route.query.caseNo || this.$route.params.caseNo; if (!this.caseNo) { this.$message.error('Missing caseNo'); return; } await this.loadCompareData(); }, methods: { async loadCompareData() { try { const res = await this.$http.get('/api/erc/compare-details', { params: { caseNo: this.caseNo } }); const data = res.data.data; this.stepForms = data.stepForms || []; this.compareInfos = data.compareInfos || {}; this.ercAllStep = data.ercAllStep || Object.keys(this.compareInfos); this.mesAllStep = data.mesAllStep || []; this.holdStepNo = data.holdStepNo || ''; this.ercStepNo = data.ercStepNo || ''; this.ercStepLength = this.ercAllStep.length; this.mesStepLength = this.mesAllStep.length; } catch (err) { this.$message.error('Failed to load compare data'); console.error(err); } }, isPhotoArea(area) { return area && area.toLowerCase().includes('photo'); } } }; </script> <style scoped> .center { text-align: center; font-weight: bold; font-size: 18px; color: #1890ff; } .compare-table { background-color: #ffffff; border-collapse: collapse; margin: 0 auto; } .compare-table th, .compare-table td { padding: 6px 10px; text-align: left; } .compare-table .center { text-align: center; } .compare-table .b { background-color: #f9f9f9; } .compare-table .mes-header { color: #808000; font-weight: bold; } .compare-table .mes-cell { color: #808000; font-weight: bold; } .separator { line-height: 10px; } .error-row span { font-size: 14px; } /* 隐藏滚动条但保留功能 */ ::-webkit-scrollbar { display: none; } </style> 仍旧报错98% after emitting SizeLimitsPlugin ERROR Failed to compile with 1 error 17:37:26 error in ./src/pages/mlcs/NewApplication/Mlcs/CompareResult.vue?vue&type=template&id=25a405a5&scoped=true& Syntax Error: Unexpected token (1:1355) @ ./src/pages/mlcs/NewApplication/Mlcs/CompareResult.vue?vue&type=template&id=25a405a5&scoped=true& 1:0-466 1:0-466 @ ./src/pages/mlcs/NewApplication/Mlcs/CompareResult.vue @ ./src/router/config.js @ ./src/router/index.js @ ./src/main.js @ multi (webpack)-dev-server/client?http://10.107.112.67:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js babel-polyfill whatwg-fetch ./src/main.js
最新发布
12-10
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值