我正在尝试创建大约十二个TextField,并且想知道是否存在一种快速简便的方法。
const cars = [
{ model: "convertible", year: "2015", use: "sports" },
{ model: "wagon", year: "2013", use: "family" }
];
const buyers = [
{ name: "John", searchingUse: "family", maxYear: "2014", maxPrice: "15000" },
{ name: "Mark", searchingUse: "ddd", maxYear: "2012", maxPrice: "1000" }
];
const a = buyers
.map(buyer => ({
[buyer.name]: cars.filter(car => car.use === buyer.searchingUse)
}));
console.log(a);
我觉得有一种我不知道的更有效的方法
答案 0 :(得分:4)
您可以使用简单的for
循环将新的TextField
添加到List
:
List<TextField> timeTextFields = new ArrayList<>();
for (int i = 0; i < 5; i++) {
timeTextFields.add(new TextField("Time #" + i));
}