home.tsx 566 B

12345678910111213141516171819202122232425
  1. import { useMemo } from 'react'
  2. import type CustomTabBar from '../../custom-tab-bar'
  3. import { View, Text } from '@tarojs/components'
  4. import Taro, { useLoad, useDidShow } from '@tarojs/taro'
  5. import './home.less'
  6. export default function Index() {
  7. const page = useMemo(() => Taro.getCurrentInstance().page, [])
  8. useLoad(() => {
  9. console.log('Page loaded.')
  10. })
  11. useDidShow(() =>{
  12. const tabbar = Taro.getTabBar<CustomTabBar>(page)
  13. tabbar?.setSelected(1)
  14. })
  15. return (
  16. <View className='index'>
  17. <Text>Hello world!</Text>
  18. </View>
  19. )
  20. }