如何使用wix corvid将循环数据连接到pdfgeneratorapi?

我正在使用https://pdfgeneratorapi.com/生成 PDF 。

现在我可以使用这段代码一个一个地显示数据。任何人都可以给我建议如何用循环或任何其他方式显示所有数据吗?下面的照片显示了我来自 pdfgenerator 的模板。

http://img3.mukewang.com/63b78aab000126fe09800177.jpg

这是我用来生成 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);

    } );



绝地无双
浏览 283回答 2
2回答

阿波罗的战车

只需将它放在带有布尔条件的 while 循环中即可。您可以创建一个变量,例如allShowed,并将其值设置为False。之后,创建另一个变量,例如numberOfDataToShow,并将其设置为您要显示的元素数。然后创建一个计数器,countShowed,初始化0为它的值。现在创建一个 while 循环:当allShowed值为时False,您循环(并添加数据)。每次显示一条数据时,您都会增加的值countShowed(并将其设置为继续添加/显示数据)。当countShowed将具有完全相同的值时numberOfDataToShow,设置allShowed为True。循环将中断并显示所有数据。

繁星coding

您需要使用 PDF Generator API 中的Container或Table组件来迭代项目列表。正如@JustCallMeA 所说,您需要发送一系列项目。PDF 生成器 API 现在有一个带有演示页面的官方 Wix Velo(以前称为 Corvid)教程:https: //support.pdfgeneratorapi.com/en/article/how-to-integrate-with-wix-velo-13s8135
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript