30 lines
636 B
TypeScript
30 lines
636 B
TypeScript
import { View, Text } from '@tarojs/components';
|
|
import { Component, ReactNode } from 'react';
|
|
import Taro from '@tarojs/taro';
|
|
import type CustomTabBar from '../../custom-tab-bar';
|
|
import './index.scss';
|
|
|
|
class Index extends Component {
|
|
state = {
|
|
msg: 'Hello World!',
|
|
};
|
|
|
|
// 以下是TabBar相关
|
|
pageCtx = Taro.getCurrentInstance().page;
|
|
componentDidShow() {
|
|
const tabbar = Taro.getTabBar<CustomTabBar>(this.pageCtx);
|
|
tabbar?.setSelected(0);
|
|
}
|
|
// 以上是TabBar相关
|
|
|
|
render(): ReactNode {
|
|
return (
|
|
<View>
|
|
<Text>{this.state.msg}</Text>
|
|
</View>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Index;
|