我正在构建一个火车网上预订项目,现在我需要构建一个选择框,选项值根据预订表单而变化。
//select-box <custom-select-box label="Travel" v-model="form.InfantWithAdult" :items="travel" ></custom-select-box>
5uzkadbs1#
尝试使用forEach:
travelWith() { let travellerlist = []; let adults = this.passengers.filter( (x) => x.PaxType === "ADT" && x.SSR.Outbound.filter((y) => { return y.codeType === "INFT"; }).length > 0 ); if (adults.length > 0) { let nr = 1; let travel = null; // 👇 loop all adults and add to travellerlist array adults.forEach(adult => { if (!adult.FirstName) { travel = `Adult ${nr++}`; } else if (adult.FirstName !== "" && adult.LastName !== "") { travel = `Adult ${nr++} ${adult.Title} ${adult.FirstName} ${adult.LastName}`; } travellerlist.push(travel); }) } return travellerlist; },
1条答案
按热度按时间5uzkadbs1#
尝试使用forEach: