weixin_33720186 2020-02-04 15:25 采纳率: 0%
浏览 40

带提取的EJS流

I am curious, is it possible to livestream data from an api without reloading the page. I'm interested in redeclaring all variables that the view/page was rendered with from start of - Make a async fetch in the background, which then will redeclare the variables and rerender them in some manner.

I'm not quite sure to which approach i should have - it's basicly an idea where i have school activities fetched from an api and rendered through ejs. But i would like a realtime effect, where as i don't need to reload the page to make another fetch to see the variables being rerendered with the fresh data??

I know i could make an AJAX call on the clientside, which means i would have to rewrite my ejs file But that's not what i'm looking for...

Is it possible to livestream data with ejs in any way?

        <svg class="Bg" viewBox="0 0 201.305 94">
          <path fill="rgba(50,50,69,1)" class="pathBg" d="M 0 0 L 201.3046875 0 L 201.3046875 94 L 0 94 L 0 0 Z">
          </path>
        </svg>
        <svg class="before" viewBox="0 0 16 94">
          <% switch (elem.color) {
            case "green": %>
            <path fill="#78952b" class="pathbefore" d="M 0 0 L 16 0 L 16 94 L 0 94 L 0 0 Z">
                    <% break;
            case "red": %>
            <path fill="#A83331" class="pathbefore" d="M 0 0 L 16 0 L 16 94 L 0 94 L 0 0 Z">
                    <% break;
            case "purple": %>
            <path fill="#7D2772" class="pathbefore" d="M 0 0 L 16 0 L 16 94 L 0 94 L 0 0 Z">
                    <% break;
            case "blue": %>
            <path fill="#3674B5" class="pathbefore" d="M 0 0 L 16 0 L 16 94 L 0 94 L 0 0 Z">
                    <% break;
            default: case "grey": %>
            <path fill="#808080" class="pathbefore" d="M 0 0 L 16 0 L 16 94 L 0 94 L 0 0 Z">
                    <% break;
            } %>


          </path>
        </svg>
        <div class="holdNavn">
          <span><%= elem.class %></span>
        </div>
        <svg class="tidBg" viewBox="0 0 167 19">
          <path fill="rgba(36,36,57,1)" class="pathtidBg"
            d="M 9.5 0 L 157.5 0 C 162.7467041015625 0 167 4.253294467926025 167 9.5 C 167 14.74670600891113 162.7467041015625 19 157.5 19 L 9.5 19 C 4.253294467926025 19 0 14.74670600891113 0 9.5 C 0 4.253294467926025 4.253294467926025 0 9.5 0 Z">
          </path>
        </svg>
        <div class="hold">
          <span>Hold</span>
        </div>
        <div class="emneNavn">
          <span><%=  elem.friendly_name %></span>
        </div>
        <div class="emne">
          <span>Emne</span>
        </div>
        <div class="tidStart">
          <span><%= elem.time %></span>
        </div>
        <div class="lokaleNummer">
          <span><%= elem.classroom %></span>
        </div>
        <div class="tid">
          <span>Tid</span>
        </div>
        <div class="lokale">
          <span>Lokale</span>
        </div>
      </div>

      <% }) %>
    </div>```




  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 fluent的在模拟压强时使用希望得到一些建议
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用
    • ¥15 Web.config连不上数据库
    • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
    • ¥15 怎么配置广告联盟瀑布流
    • ¥15 Rstudio 保存代码闪退