我有一个对象数组,将通过 DocXTemplater 导出到 word 文档
样本数组
[
{Name:"jon doe",age:27}
{Name:"joe roe",age:27,Address:"new jersey"}
]
现在 DocXTemplate 将是
{#arrayVarName}{Name},{age},{Address}{/arrayVarName}
这将输出,
Jon,27,undefined
Joe,27,new jersey
现在我想过滤所有未定义的并用空字符串或一些自定义字符串替换它们,这如何在 DocXTemplater 中完成,或者对象数组中的所有未定义是否可以替换为自定义字符串?
最佳答案
您现在可以全局自定义此设置:
doc=new DocxGen(content);
doc.setOptions({nullGetter: function() {
return "";
}});
关于javascript - 处理 docXTemplater 或 javascript 对象数组中的未定义值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37179098/