組件實際上按照它應該的方式工作,但每次更改標籤時,警告被拋出: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(如果您正確配置它)到導航,它將被突出顯示,就像在文檔示例 –