Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery firestore索引计数器总大小_Jquery_Firebase - Fatal编程技术网

Jquery firestore索引计数器总大小

Jquery firestore索引计数器总大小,jquery,firebase,Jquery,Firebase,我有多个信息,正在尝试从firestore中提取div分配id,即幻灯片1。 如何创建每个div的索引,如幻灯片1、幻灯片2 同时加载所有信息,如附加图像。 我必须触发一些操作才能正常工作,可能需要手动调整窗口大小 JQuery 在foreach之前创建一个count变量,并在每个foreach中递增它。然后用count替换1 docRef .orderBy("order") .get() .then(querySnapshot => { totalRe

我有多个信息,正在尝试从firestore中提取div分配id,即幻灯片1。 如何创建每个div的索引,如幻灯片1、幻灯片2

同时加载所有信息,如附加图像。 我必须触发一些操作才能正常工作,可能需要手动调整窗口大小

JQuery


在foreach之前创建一个count变量,并在每个foreach中递增它。然后用count替换1

docRef
    .orderBy("order")
    .get()
    .then(querySnapshot => {
      totalRecords = querySnapshot.size;
      console.log(totalRecords);
      let count = 0;
      querySnapshot.forEach(doc => {
        const data = doc.data();
        // console.log(data.title);
        count++;
        const slide =
          `
        <div id="slide-`+ count +`" class="slide fullbleed prt"><div
            class="bg-image"
            style="background-image: url(`+ data.imgPath + `);"
          />
          <div class="screen" />
          <div class="wrap">
            <div class="entry">
              <h2>`+ data.title +`</h2>
              <h4>`+ data.tagline +`<//h4>

              <span
                class="play-button button"
                data-vimeo-id="`+ data.vimeo +`"
                data-vimeo-iframe='&lt;iframe src="https://player.vimeo.com/video/`+ data.vimeo +`?dnt=1&amp;app_id=122963" width="1920" height="1080" frameborder="0" title="Hennessy X.O - The Seven World" allow="autoplay; fullscreen" allowfullscreen&gt;&lt;/iframe&gt;'
              >
                Play
              </span>
            </div>
          </div>
        </div>;
        `;

        $(".slideshow").append(slide);
      });
    });
  };

我以前试过这个。使用幻灯片中的计数后站点不显示任何数据检查页面时div id是什么?或者控制台中是否存在任何控制台错误?是的,其工作正常,有一些额外的}导致问题。你能帮我解决一下吗,我如何修复其余的数据?问题是什么?我不太了解它。数据库有3个项目,每个项目都有图像、标题、标语,它们的抓取效果非常好,但一旦我在前端调用,第一个项目的标题就会显示在第三个互动程序上
docRef
    .orderBy("order")
    .get()
    .then(querySnapshot => {
      totalRecords = querySnapshot.size;
      console.log(totalRecords);
      let count = 0;
      querySnapshot.forEach(doc => {
        const data = doc.data();
        // console.log(data.title);
        count++;
        const slide =
          `
        <div id="slide-`+ count +`" class="slide fullbleed prt"><div
            class="bg-image"
            style="background-image: url(`+ data.imgPath + `);"
          />
          <div class="screen" />
          <div class="wrap">
            <div class="entry">
              <h2>`+ data.title +`</h2>
              <h4>`+ data.tagline +`<//h4>

              <span
                class="play-button button"
                data-vimeo-id="`+ data.vimeo +`"
                data-vimeo-iframe='&lt;iframe src="https://player.vimeo.com/video/`+ data.vimeo +`?dnt=1&amp;app_id=122963" width="1920" height="1080" frameborder="0" title="Hennessy X.O - The Seven World" allow="autoplay; fullscreen" allowfullscreen&gt;&lt;/iframe&gt;'
              >
                Play
              </span>
            </div>
          </div>
        </div>;
        `;

        $(".slideshow").append(slide);
      });
    });
  };