对接api

This commit is contained in:
2022-05-09 10:03:33 +08:00
parent e7a130533d
commit 4c46c6e22d
16 changed files with 243 additions and 184 deletions
@@ -1,15 +1,16 @@
import { Image, Swiper, SwiperItem, View } from "@tarojs/components"
import { useMemo, useState } from "react"
import { useMemo, useRef, useState } from "react"
import styles from './index.module.scss'
type item = {title:string, img:string, url:string, id:number}
type params = {
list?: item[]
}
}
export default ({list = []}: params) => {
const [pageIndex, setPageIndex] = useState(1)
const pageRef = useRef<any>(null)
const pageCount = useMemo(() => {
return list.length
@@ -17,7 +18,9 @@ export default ({list = []}: params) => {
const swiperChange = (e) => {
setPageIndex(e.detail.current + 1)
pageRef.current.innerHTML = 2
}
return (
<View className={styles.swiper}>
@@ -30,7 +33,7 @@ export default ({list = []}: params) => {
</SwiperItem>
})}
</Swiper>
<View className={styles.page}>{pageIndex+'/'+pageCount}</View>
<View className={styles.page} ref={pageRef}>{pageIndex+'/'+pageCount}</View>
</View>
)
}