reactjs - 如何在 ResultCard 中显示搜索结果中的详细信息页面?
问题描述
前提条件:使用 appbaseio/reactivesearch 响应应用程序
问题:当我单击搜索结果时,我试图在同一窗口中打开一个简单的详细信息页面(例如,作为通过onclick处理程序触发的弹出窗口)。ResultCard 组件正在显示搜索结果。有人遇到过类似的问题并解决了吗?
我看到 ResultCard 组件中有 url 参数(此处为:“profile”),但它只是重定向到另一个选项卡窗口中的指定 url。
import {ReactiveBase, DataSearch, ResultCard} from
appbaseio/reactivesearch";
// ...some more code
<div className="container">
// connector to appbase.io
<ReactiveBase
app="myapp"
credentials="xxx"
theme={{
primaryColor: "#ffe067"
}}
>
// search bar
<DataSearch
componentId="SearchSensor"
dataField={["gebot_name", "info"]}
className="search"
/>
// display search results in a list with title and description
<ResultCard
className="right-col"
componentId="SearchResult"
size={10}
onData={data => ({
title: data.gebot_name,
description: data.description,
url: "profile"
})}
react={{
and: ["SearchSensor"]
}}
/>
</ReactiveBase>
</div>
解决方案
因此,根据我从您的问题中了解到的情况,您希望在单击结果项时显示模态并显示所有详细信息。
如果是这种情况,您可以ReactiveList
根据自己的选择使用和呈现数据。例如:
在v2
:
<ReactiveList
...
onData={ res => (
<div onClick={() => this.handleModal(res)} >{Content}</div>
)
}
/>
您可以处理模态并this.handleModal
显示数据。
在v3
<ReactiveList
...
renderItem={ res => (
<div onClick={() => this.handleModal(res)} >{Content}</div>
)
}
/>
在此处查看文档:
对于 v3:https ://opensource.appbase.io/reactive-manual/result-components/reactivelist.html
对于 v2:https ://opensource.appbase.io/reactive-manual/v2/result-components/reactivelist.html
推荐阅读
- sql - Oracle SQL:使用 REGEXP_SUBSTR 提取特定单词之前的文本
- python - 合并两个没有重复的 DF
- python - 两个 4D numpy 数组中所有行的组合
- c# - 如何将 .NET Core ASP 应用程序连接到 MS Access 数据库
- javascript - JavaScript/jQuery:如何在显示 Bootstrap 模式后运行 DataTables
- excel - 如何更改命名范围的引用?
- xamarin - 拒绝访问路径 /Documents
- windows - 为多个分区配置 Hive 注册表存储
- r - 具有字符向量的数据帧的快速聚合
- json - Ruby Sinatra JSON 设置