【问题标题】:Include external html into enduro.js在 enduro.js 中包含外部 html
【发布时间】:2019-03-12 21:54:36
【问题描述】:

我有一个基于本教程的 enduro.js 博客:

https://www.endurojs.com/blog/how-to-make-a-blog-with-endurojs

我想将导航栏和页脚添加为某些 URL 上可用的外部 .html 文件。如何在以下代码中包含一些导航栏 URL,即组件“header.hbs”:

<header>
    <div class="inner">
        <h1><a href="{{global.base_url}}">{{global.site_name}}</a></h1>
        {{#if global.site_description}}
            <p>{{global.site_description}}</p>
        {{/if}}
    </div>

</header>
<nav class="aSiteNav" id="navbarDiv">
    <div class="inner">
        {{#if global.show_archive_link}}
            <a href="/blog/archive/">{{global.archive_link_text}}</a>
        {{/if}}
        {{#navlinks}}
            {{#each this}}
                <a href="/blog/pages/{{this.page_slug}}/">{{this.content.navigation_title}}</a>
            {{/each}}
        {{/navlinks}}
    </div>
</nav>

【问题讨论】:

    标签: javascript html enduro.js


    【解决方案1】:

    你可以试试这样的

    <header>
        <iframe id="inlineFrameExample" src="{{url_of_your_header}}"></iframe>
    </header>
    

    【讨论】:

    • 谢谢,但这不起作用,我只是得到“错误处理页面”
    • iframe 标签没有关闭,现在应该可以了。无论如何,您的解决方案也是有效的。
    【解决方案2】:

    我通过包含 jquery 来解决它:

    <header>
       <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
       <script>
          $(function(){
            $("#navbar").load("https://mydomain.xyz/navbar.html");
          });
       </script>  
       <div class="inner" id="navbar">
       </div>
    </header>
    

    【讨论】:

      猜你喜欢
      • 2019-01-01
      • 2018-10-26
      • 2013-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-23
      • 1970-01-01
      相关资源
      最近更新 更多