Skip to content
This repository has been archived by the owner on Jul 2, 2022. It is now read-only.

安装的搜索插件似乎工作不太正常 #166

Open
Marssssssss opened this issue May 28, 2022 · 0 comments
Open

安装的搜索插件似乎工作不太正常 #166

Marssssssss opened this issue May 28, 2022 · 0 comments

Comments

@Marssssssss
Copy link

按照 README 下面的配置搜索插件流程安装的插件,出现搜索功能失效的问题。

描述:
1、hexo g 之后直接刷新搜索页面,功能正常,可以进行搜索;
2、hexo g 之后先打开主页再点击搜索按钮进入搜索框,功能不正常,无法正常搜索。

本地 patch 方案:
情形 2 发生之后,打开控制台,有一个 trace 的调用栈指向 searchFunc 这个函数,似乎是从 jquery 那个脚本调用过来的。根据错误内容推断是调用到这里的时候 id 为 local-search-input 的页面元素没有,导致拿到的对象是 null,于是下面注册监听回调的函数就报错了。
然后我跟了一下,打开搜索页面之后 local-search-input 这个页面元素其实是有的,于是怀疑是调用时序的问题,于是用 setTimeout 先打补丁绕过去了,顺便过来报个 issue~

(原谅我没有丰富的 js 和 jquery 使用经验,加上 jquery 脚本似乎是混淆过的,我这样省时间做了一个绕过的手段,但我不能确定这么绕过是否会有风险,希望得到解答~)

@Marssssssss Marssssssss changed the title 安装的搜索插件在我这边似乎工作不太正常 安装的搜索插件似乎工作不太正常 May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant