hexo 5 安装 Next 主题后, 侧边栏目录中中文目录锚点点击后无法正常跳转
问题定位
知道是 ‘post-details.js’ 文件报错后就简单了. 阅读源码后我们发现是 targetSelector 解析 UTF8 有问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
$('.post-toc a').on('click', function (e) { e.preventDefault(); <!-- targetSelector 解析UTF8的问题 -> var targetSelector = NexT.utils.escapeSelector(this.getAttribute('href')); var offset = $(targetSelector).offset().top;
hasVelocity ? html.velocity('stop').velocity('scroll', { offset: offset + 'px', mobileHA: false }) : $('html, body').stop().animate({ scrollTop: offset }, 500); });
|
Bugfix
将 targetSelector 再解析一次就好了
1 2 3 4
| var targetSelector = NexT.utils.escapeSelector(this.getAttribute('href')); <!-- 添加下面这行代码, 重新解析 URL -> targetSelector = decodeURI(this.getAttribute('href')) var offset = $(targetSelector).offset().top;
|
原文链接:https://blog.csdn.net/qq_42009500/article/details/116129303