|
@@ -1,10 +1,15 @@
|
1
|
|
-import React, { useState } from 'react'
|
|
1
|
+import React, { Suspense, useState, lazy } from 'react'
|
2
|
2
|
import { View, Text } from '@tarojs/components'
|
3
|
3
|
import CustomNav from '@/components/CustomNav'
|
4
|
4
|
import logo from '@/assets/icons/comm/logo_small.png'
|
5
|
5
|
import tabList from './tabbar'
|
6
|
6
|
import './index.less'
|
7
|
7
|
|
|
8
|
+const Recommend = lazy(() => import('./tabs/Recommend'))
|
|
9
|
+const Guide = lazy(() => import('./tabs/Guide'))
|
|
10
|
+const Strategy = lazy(() => import('./tabs/Strategy'))
|
|
11
|
+const Mine = lazy(() => import('./tabs/Mine'))
|
|
12
|
+
|
8
|
13
|
export default (props) => {
|
9
|
14
|
const [currentTab, setCurrentTab] = useState(0)
|
10
|
15
|
|
|
@@ -19,6 +24,12 @@ export default (props) => {
|
19
|
24
|
<CustomNav logo={logo} title='首页' />
|
20
|
25
|
</view>
|
21
|
26
|
<view className='index-container'>
|
|
27
|
+ <Suspense fallback='loading...'>
|
|
28
|
+ {currentTab === 0 && <Recommend />}
|
|
29
|
+ {currentTab === 1 && <Guide />}
|
|
30
|
+ {currentTab === 2 && <Strategy />}
|
|
31
|
+ {currentTab === 3 && <Mine />}
|
|
32
|
+ </Suspense>
|
22
|
33
|
</view>
|
23
|
34
|
<view className='index-tabbar'>
|
24
|
35
|
<mp-tabbar extClass='custom-tabbar' current={currentTab} list={tabList} onChange={handleTabChange}></mp-tabbar>
|