javascript - 将外部 html 包含到 enduro.js 中

标签 javascript html enduro.js

我有一个基于本教程的 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>

最佳答案

我通过包含 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>

关于javascript - 将外部 html 包含到 enduro.js 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52698680/

相关文章:

javascript - 来自数据库的下拉菜单值和更新列表 onChange

html - 在 HTML 和 CSS 中显示与菜单项内联的 Logo

javascript - 单击时检索 jQuery 数组元素的值

html - 无法覆盖 Bootstrap 的默认版式和标题 CSS 样式

javascript - 来自外部文件中服务的 ag-grid 绑定(bind)

javascript - 更改 dijit 布局 tabcontainer 中一系列选项卡中一个选项卡的标签颜色

node.js - 如何在 Enduro.js 中启用 JS 编译

javascript - 理解 ajax 中的 http 请求和嵌套函数

javascript - 在handlebars/endurojs 中为博客创建标签过滤器