絕地無雙
2023-01-06 10:42:25
我正在使用https://pdfgeneratorapi.com/生成 PDF 。現在我可以使用這段代碼一個一個地顯示數據。任何人都可以給我建議如何用循環或任何其他方式顯示所有數據嗎?下面的照片顯示了我來自 pdfgenerator 的模板。這是我用來生成 PDF 的代碼 let communicationWay1=[ {0:"dim"}, {1:"kal"} ]; let cstomerExpence1=[ {0:"dim"}, {1:"kal"} ]; let title="test"; let names="test"; let phone="test"; let email="test";let maritalStatus="test";let city="test";let other="test"; const result = await wixData.query(collection) .eq('main_user_email', $w('#mainE').text) .find() .then( (results) => { if (results.totalCount>0) { count=1; // title=results.items[1].title; names=results.items[0].names; email=results.items[0].emial; phone=results.items[0].phone; maritalStatus=results.items[0].maritalStatus; city=results.items[0].city; other=results.items[0].cousterExpenses_other; title=results.items[0].title; communicationWay=results.items[0].communicationWay; cstomerExpence=results.items[0].cstomerExpence; } if (results.totalCount>1) { names1=results.items[1].names; email1=results.items[1].emial; phone1=results.items[1].phone; maritalStatus1=results.items[1].maritalStatus; city1=results.items[1].city; other1=results.items[1].cousterExpenses_other; title1=results.items[1].title; communicationWay1=results.items[1].communicationWay; cstomerExpence1=results.items[1].cstomerExpence; } } ) .catch( (err) => { console.log(err); } );
2 回答

阿波羅的戰車
TA貢獻1862條經驗 獲得超6個贊
只需將它放在帶有布爾條件的 while 循環中即可。
您可以創建一個變量,例如allShowed
,并將其值設置為False
。之后,創建另一個變量,例如numberOfDataToShow
,并將其設置為您要顯示的元素數。然后創建一個計數器,countShowed
,初始化0
為它的值。
現在創建一個 while 循環:當allShowed
值為時False
,您循環(并添加數據)。每次顯示一條數據時,您都會增加的值countShowed
(并將其設置為繼續添加/顯示數據)。當countShowed
將具有完全相同的值時numberOfDataToShow
,設置allShowed
為True
。循環將中斷并顯示所有數據。

繁星coding
TA貢獻1797條經驗 獲得超4個贊
您需要使用 PDF Generator API 中的Container或Table組件來迭代項目列表。正如@JustCallMeA 所說,您需要發送一系列項目。PDF 生成器 API 現在有一個帶有演示頁面的官方 Wix Velo(以前稱為 Corvid)教程:https: //support.pdfgeneratorapi.com/en/article/how-to-integrate-with-wix-velo-13s8135
添加回答
舉報
0/150
提交
取消