gpt4 book ai didi

javascript - 将值从一个选项卡传递到 ReactJs 中的另一个选项卡

转载 作者:行者123 更新时间:2023-11-29 15:58:50 27 4
gpt4 key购买 nike

我正在研究 ReactJS,想知道如何在选项卡之间传递值。

下面是我正在处理的组件。我有三个选项卡,想在单击接受按钮时将卡片从一个选项卡传递到另一个选项卡。

import React, { Component } from 'react'
import DriverPlacedOrder from './DriverPlacedOrder';
import {Link }from 'react-router-dom';
import {Tabs,Tab} from 'react-bootstrap';

export default class Driver extends Component {

constructor(props, context) {
super(props, context);
this.state = {
key: 'home',
};
}
render() {
return (
<Tabs
id="controlled-tab-example"
activeKey={this.state.key}
onSelect={key => this.setState({ key })}
>
<Tab eventKey="newOrder" title="New Order">

<div class="container">
<div class="card" style={{width:'100%',borderRadius:'2%', border: '4px solid lightgreen'}}>
<div class="card-body" style={{textAlign:'center'}}>
<h4 class="card-title">{CID}</h4>
<p class="card-text"><h5>{RID}</h5></p>
<Button variant="outline-success"onClick={} style={{width:'33%'}}><i class="fas fa-check-circle fa-lg"></i><br/>Accept</Button>
<Button variant="outline-primary" style={{width:'33%'}}><i class="fas fa-book-open fa-lg" fa-lg></i><br/>View</Button>

</div>
</div>
</div>

</Tab>
<Tab eventKey="currentOrder" title="Current Order">

</Tab>
<Tab eventKey="orderHistory" title="OrderHistory">

</Tab>
</Tabs>
);
}
}

点击接受按钮后,如何将卡片从 NewOrder 选项卡传递到 currentOrder 选项卡?

最佳答案

I am working on ReactJS and was wondering on how can I pass value between tabs.

<Tab my_data={my_data_value} eventKey="orderHistory" title="OrderHistory">
</Tab>

关于javascript - 将值从一个选项卡传递到 ReactJs 中的另一个选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55564229/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com