关于gitbook 使用3.2.3版本,导致build编译后的自动生成的左侧目录无法跳转问题的解决办法

当前使用gitbook在写一些文档,但使用导出编译git build 后,生成的静态HTML页面,无法翻页到上下章节。 但放在服务器上线上就正常。于是乎是去查询相关资料。目前方法有二。如下:

当前gitbook版本   3.2.3 

# gitbook --version
# CLI version: 2.3.2
# GitBook version: 3.2.3

方法一,使用 2.6.7 这个版本就可以   。

git build  --gitbook=2.6.7

 # gitbook build --gitbook=2.6.7

方法二,修改相关文件。

  • 在导出的文件夹目录下找到gitbook->theme.js文件
  • 找到下面的代码(搜索 if(m)for(n.handler&&
if(false)for(n.handler&&(i=n,n=i.handler,o=i.selector),o&&de.find.matchesSelector(Ye,o),n.guid||(n.guid=de.guid++),(u=m.events)||(u=m.events={}),(a=m.handle)||(a=m.handle=function(t){return"undefined"!=typeof de&&de.event.triggered!==t.type?de.event.dispatch.apply(e,arguments):void 0}),t=(t||"").match(qe)||[""],l=t.length;l--;)s=Ze.exec(t[l])||[],h=g=s[1],d=(s[2]||"").split(".").sort(),h&&(f=de.event.special[h]||{},h=(o?f.delegateType:f.bindType)||h,f=de.event.special[h]||{},c=de.extend({type:h,origType:g,data:r,handler:n,guid:n.guid,selector:o,needsContext:o&&de.expr.match.needsContext.test(o),namespace:d.join(".")},i),(p=u[h])||(p=u[h]=[],p.delegateCount=0,f.setup&&f.setup.call(e,r,d,a)!==!1||e.addEventListener&&e.addEventListener(h,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),o?p.splice(p.delegateCount++,0,c):p.push(c),de.event.global[h]=!0)}

将if(m)改成if(false)

问题完美解决

posted @ 2022-01-25 18:05  树下水月  阅读(220)  评论(0编辑  收藏  举报