javascript - 对于使用 algolia api 的 javascript 的前端,我如何禁用荧光笔
问题描述
我在搜索时使用 Algolia API 进行搜索,它给了我结果,但它突出显示了我不想突出显示的文本
const search = instantsearch({
indexName: 'testing',
searchClient,
routing: true,
attributesToHighlight: [],
searchFunction(helper) {
const container = document.querySelector('#hits');
container.style.display = helper.state.query === '' ? 'none' : '';
helper.search();
}
});
search.addWidgets([
instantsearch.widgets.searchBox({
container: '#show_search_list',
placeholder: 'Search for Email',
showReset: false,
templates: {
submit: 'GO',
}
})
]);
search.addWidgets([
instantsearch.widgets.hits({
container: '#hits',
templates: {
item:
`
<p>{{#helpers.highlight}}{ "attribute": "full_name" }{{/helpers.highlight}}</p>
<p>{{#helpers.highlight}}{ "attribute": "email" }{{/helpers.highlight}}</p>
`,
empty: `We didn't find any results for the search <em>"{{query}}"</em>`,
},
})
]);
我阅读了文档,但没有找到与我的要求相关的任何内容
解决方案
我找到了它,并将此 {{#helpers.highlight}}{ "attribute": "full_name" }{{/helpers.highlight}} 更改为此 {{full_name}} 并且它的工作正常,因为 helpers.highlight 使属性突出显示。现在它对我来说很好用
推荐阅读
- php - 从浏览器加载带有 VPA 和 AMOUNT 的 UPI 应用程序
- javascript - 如何在单元测试中使用 TypeORM 全局 createConnection()?
- android - Android:如何在父活动及其按钮/导航视图上显示片段
- spring-boot - Spring Boot 应用程序 - 不读取 Tomcat 中的 application.properties,但在 Spring Tool Suite 下工作
- javascript - MongoDB:从 mongodb 下载后 Zip 文件错误
- coq - 如何在不取消 coq 中的积极性检查的情况下使用这些归纳法?
- python - Matplotlib 颜色图设置为低于阈值的黑色
- c# - 如何在循环的每次迭代中增加作为字符串一部分的整数
- javascript - Vue 不会渲染其中一个组件。没有错误,甚至显示在 DOM 中,看起来都适合我
- c# - Unity 3D: Footstep sounds looping the first few milliseconds instead of playing the full sound then looping