组件实际上按照它应该的方式工作,但每次更改标签时,警告被抛出:Reac-bootstrap:警告:不支持在“<TabContainer>”的上下文中指定`<Nav>``activeKey`或`activeHref`
Warning: Specifying a `<Nav>` `activeKey` or `activeHref` in the
context of a `<TabContainer>` is not supported. Instead use
`<TabContainer activeKey={First} />`.
不知道如何压制它!
我正在用MobX商店控制activeKey
。这里有一个例子:
<Tab.Container defaultActiveKey={"first"} activeKey={store.key} onSelect={store.handleSelect} >
<NavigationBar store = {this.store}/>
<Tab.Content animation={false} >
<Tab.Pane eventKey={"first"} >
<FirstTab store = {this.store} eventKey={"first"} />
</Tab.Pane>
<Tab.Pane unmountOnExit={true} eventKey={"second"}>
<SecondTab store = {this.store} />
</Tab.Pane>
<Tab.Pane unmountOnExit={true} eventKey={"third"}>
<ThirdTab store = {this.store} />
</Tab.Pane>
</Tab.Content>
</Tab.Container>
,并在我的店里MobX:
@observable key = "First";
@action handleSelect = (key) => {
this.key = key;
if(key === undefined){
this.key = "First"
}
};
而且NavigationBar
组件:
<Nav bsStyle="tabs" activeKey={this.props.store.key} >
<NavItem eventKey={"First"}>
// Some icon
</NavItem>
<NavItem eventKey={"Second"}>
// Some icon
</NavItem>
<NavItem eventKey={"Third"}>
// Some icon
</NavItem>
</Nav>
至于说,一切都按预期工作。每当标签页的状态发生变化时,我就会在我的脸上看到这个警告。
我必须在'Nav'上指定它,因为否则,所选标签将不会在单击事件中突出显示。这是我在那里的唯一原因,事实上: -/ – cbll
这是不正确的,TabContainer会通过activeKey(如果您正确配置它)到导航,它将被突出显示,就像在文档示例 –