小编per*_*ode的帖子

在 React 中使用 Ant Design 切换选项卡中的按钮?

希望在选项卡主体中放置一个按钮,该按钮只会切换到下一个选项卡,反之亦然。我已经玩了几个小时了,但找不到方法来做到这一点。任何帮助表示赞赏

import { Tabs } from 'antd';

const { TabPane } = Tabs;

function callback(key) {
  console.log(key);
}

const Demo = () => (
  <Tabs defaultActiveKey="1" onChange={callback}>
    <TabPane tab="Tab 1" key="1">
      Content of Tab Pane 1 
      <button type="button">
         Go to tab 2
      </button>
    </TabPane>
    <TabPane tab="Tab 2" key="2">
      Content of Tab Pane 2
    </TabPane>
    <TabPane tab="Tab 3" key="3">
      Content of Tab Pane 3
    </TabPane>
  </Tabs>
);

ReactDOM.render(<Demo />, mountNode);
Run Code Online (Sandbox Code Playgroud)

javascript jsx reactjs antd

4
推荐指数
1
解决办法
5326
查看次数

标签 统计

antd ×1

javascript ×1

jsx ×1

reactjs ×1