美文网首页
hexo 博客修改全局jquery

hexo 博客修改全局jquery

作者: hebiris | 来源:发表于2019-02-25 18:34 被阅读0次

    前言

    • 环境
    hexo: "3.7.1"
    theme: landscape
    浏览器:谷歌
    
    • 问题
    GET https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js net::ERR_TIMED_OUT
    
    • 思路
      由于jquery地址只支持http请求,故需要更换此地址,才能正常加载。查看index的文件发现此连接是在文件尾部的,故需要找到生产index文件的模板文件,在里面修改。下面是我根据hexo的默认模板修改的,仅做参考。

    实现方式

    \themes\landscape\layout目录下查看layout.ejs文件,查看index文件的生成具体规则,如下:

    <%- partial('_partial/head') %>
    <body>
      <div id="container">
        <div id="wrap">
          <%- partial('_partial/header', null, {cache: !config.relative_link}) %>
          <div class="outer">
            <% if (theme.sidebar && theme.sidebar !== 'bottom'){ %>
              <%- partial('_partial/sidebar', null, {cache: !config.relative_link}) %>
            <% } %>
            <section id="main"><%- body %></section>
          </div>
          <%- partial('_partial/footer', null, {cache: !config.relative_link}) %>
        </div>
        <%- partial('_partial/mobile-nav', null, {cache: !config.relative_link}) %>
        <%- partial('_partial/after-footer') %>
      </div>
    </body>
    </html>
    

    打开themes\landscape\layout\_partial 下的after-footer.ejs文件

    将
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js "></script>
    修改成
    <script src="/js/jquery.min.js"></script>
    

    不可直接修改成http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js,因为在https下面的文件是访问http需要解决跨域问题。


    以上,便可修改hexo的全局jquery。

    相关文章

      网友评论

          本文标题:hexo 博客修改全局jquery

          本文链接:https://www.haomeiwen.com/subject/xsagyqtx.html