gpt4 book ai didi

javascript - 无法从 null 中读取属性 'length'

转载 作者:行者123 更新时间:2023-11-30 09:40:16 25 4
gpt4 key购买 nike

在 SuiteScript 中,我尝试运行已保存的搜索,但出现错误 "Cannot read property 'length' from null" 。查看我的代码:

 if(search.length>0){
layout += '<tr height="1cm">';
layout += '</tr>';
layout += '<tr>';
layout += '<td align="right" border="0px" colspan="8" style=\"font-size:12px;\">';
for(var x = 0;x<search.length;x++){
layout += iE(search[x].getText('account'))+'<br/>';
}
layout += '</td>';
}

我也试过这段代码,但结果相同。

if(search!==null %% search.length!==null){
layout += '<tr height="1cm">';

layout += '</tr>';
layout += '<tr>';
layout += '<td align="right" border="0px" colspan="8" style=\"font-size:12px;\">';
for(var x = 0;x<search.length;x++){
layout += iE(search[x].getText('account'))+'<br/>';

}
layout += '</td>';
}

最佳答案

尝试使用 &&

if(search!==null && search.length!==null){

关于javascript - 无法从 null 中读取属性 'length',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41436356/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com