Tan*_*ain 6 ionic-framework react-router ionic-react
我正在构建 Ionic React 应用程序,并且 ionic 的版本是 5。在我的应用程序中,我有底部导航。App.tsx中底部导航的逻辑我已经提到了。
我在仪表板页面上有一个添加按钮,单击该按钮我希望打开一个不包含底部导航的页面。我在互联网上得到了很多关于 Ionic-Angular 的答案。我特别在寻找答案 Ionic-React。
App.tsx
<IonContent>
<IonReactRouter>
<IonTabs>
<IonRouterOutlet>
<Route path="/profile" component={Profile} exact={true} />
<Route path="/dashboard" component={Dashboard} exact={true} />
<Route path="/dashboard/addInfo" component={Info} exact={true} />
<Route path="/" render={() => <Redirect to="/dashboard" />} exact={true} />
</IonRouterOutlet>
<IonTabBar slot="bottom">
<IonTabButton tab="home" href="/home">
<IonIcon icon={home} />
<IonLabel>Home</IonLabel>
</IonTabButton>
<IonTabButton tab="profile" href="/profile">
<IonIcon icon={profile} />
<IonLabel>Profile</IonLabel>
</IonTabButton>
<IonTabButton tab="dashboard" href="/dashboard">
<IonIcon icon={grid} />
<IonLabel>Dashboard</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
</IonReactRouter>
</IonContent>
Run Code Online (Sandbox Code Playgroud)
我做了这样的事情,这对我有用。我为选项卡创建了一个 id,然后对其进行操作以显示或隐藏
function showTab() {
const tabBar = document.getElementById('appTabBar');
if (tabBar !== null) {
console.log("enabled")
tabBar.style.display = 'flex';
}
}
function hideTab() {
const tabBar = document.getElementById('appTabBar');
if (tabBar !== null) {
tabBar.style.display = 'none';
}
}
<IonTabBar slot="bottom" id="appTabBar" >
<IonTabButton tab="account" href="/account">
<IonIcon icon={personCircleOutline}/>
<IonLabel>Profile</IonLabel>
</IonTabButton>
</IonTabBar>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1254 次 |
| 最近记录: |