我有一个 Primefaces Datatable 组件,我需要在其上放置一个自定义属性。我尝试过,<f:passThroughAttribute name="customP" value="1" />但是当它呈现时,它会将属性放入包装器 div 中,插入<table>标签。
<f:passThroughAttribute name="customP" value="1" />
<table>
有没有办法像这样发送自定义属性&l_Stack Overflow中文网
&l_Stack Overflow中文网
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法像这样发送自定义属性&l 问问题
&l 问问题
有没有办法像这样发送自定义属性<table customP="1">
<table customP="1">
这for in不是针对对象的。您正在使用一个数组,因此它的返回索引。而是使用如下所示的 forEach。
for in
var myCollection = { "cars": [ { "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] }, { "name":"BMW", "models":[ "320", "X3", "X5" ] }, { "name":"Fiat", "models":[ "500", "Panda" ] } ] } myCollection.cars.forEach(function (value) { //console.log("name" + value.name + ", models" + value.models); //for printing cars alonecars console.log(value.name); //for print models alone value.models.forEach(function (model) { console.log(model); }); });
注释下方的行将获得您想要的输出,您可以打印汽车或模型。