add tab bar

This commit is contained in:
2024-03-04 19:47:18 +08:00
parent 0713644961
commit 08fbd58c61
8 changed files with 103 additions and 6 deletions
-1
View File
@@ -1,4 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '首页',
usingComponents: {},
});
+8 -4
View File
@@ -1,6 +1,7 @@
import { View, Text } from '@tarojs/components';
import { Component, ReactNode } from 'react';
import { AtButton } from 'taro-ui';
import Taro from '@tarojs/taro';
import type CustomTabBar from '../../custom-tab-bar';
import './index.scss';
class Index extends Component {
@@ -8,14 +9,17 @@ class Index extends Component {
msg: 'Hello World!',
};
onReady() {
console.log('Index is ready');
// 以下是TabBar相关
pageCtx = Taro.getCurrentInstance().page;
componentDidShow() {
const tabbar = Taro.getTabBar<CustomTabBar>(this.pageCtx);
tabbar?.setSelected(0);
}
// 以上是TabBar相关
render(): ReactNode {
return (
<View>
<AtButton type='primary' size='normal'></AtButton>
<Text>{this.state.msg}</Text>
</View>
);
+11
View File
@@ -1,7 +1,18 @@
import { View, Text } from '@tarojs/components';
import { Component, ReactNode } from 'react';
import Taro from '@tarojs/taro';
import type CustomTabBar from '../../custom-tab-bar';
import './repair.scss';
export default class RepairPage extends Component {
// 以下是TabBar相关
pageCtx = Taro.getCurrentInstance().page;
componentDidShow() {
const tabbar = Taro.getTabBar<CustomTabBar>(this.pageCtx);
tabbar?.setSelected(1);
}
// 以上是TabBar相关
render(): ReactNode {
return (
<View>
+11
View File
@@ -1,7 +1,18 @@
import { View, Text } from '@tarojs/components';
import { Component, ReactNode } from 'react';
import Taro from '@tarojs/taro';
import type CustomTabBar from '../../custom-tab-bar';
import './user.scss';
export default class UserPage extends Component {
// 以下是TabBar相关
pageCtx = Taro.getCurrentInstance().page;
componentDidShow() {
const tabbar = Taro.getTabBar<CustomTabBar>(this.pageCtx);
tabbar?.setSelected(2);
}
// 以上是TabBar相关
render(): ReactNode {
return (
<View>