【发布时间】:2019-08-25 06:03:56
【问题描述】:
问这个问题可能很愚蠢,但相信我,我是 ReactJS 的初学者。实际上我已经在 reactjs 中实现了搜索过滤器的逻辑,我正在根据状态属性(state have all records)进行搜索过滤器,它工作正常,但基本上它渲染了存储在数据库中的所有数据。我想搜索特定数据假设我在数据库中总共有 80 条记录我想搜索特定数据,例如,如果用户类型 bla 并且它的记录存储在 Id 10 上,那么我只想渲染 Id 10 结果不喜欢存储在数据库中的完整数据。我只想渲染匹配数据,目前我正在使用 Loopback4,我正在通过 API 渲染数据。有人可以帮我解决这个问题。
谢谢
对不起:如果我因为不是母语而在英语语法上犯了错误
代码
class Example extends React.Component {
constructor(props) {
super(props);
this.state = {
Item: 5,
skip: 0
}
this.handleClick = this.handleClick.bind(this);
}
urlParams() {
return `http://localhost:3001/meetups?filter[limit]=${(this.state.Item)}&&filter[skip]=${this.state.skip}`
}
handleClick() {
this.setState({skip: this.state.skip + 1})
}
render() {
return (
<div>
<a href={this.urlParams()}>Example link</a>
<pre>{this.urlParams()}</pre>
<button onClick={this.handleClick}>Change link</button>
</div>
)
}
}
ReactDOM.render(<Example/>, document.querySelector('div#my-example' ))
【问题讨论】:
标签: javascript reactjs ecmascript-6 react-router loopbackjs