friend.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import TabBar from "@/components/navigation/TabBar";
  2. import { rpxToPx } from "@/utils/tools";
  3. import { View, Text, Image,ScrollView } from "@tarojs/components";
  4. import Taro from "@tarojs/taro";
  5. import { useEffect } from "react";
  6. export default function Friend() {
  7. const observerObjBottom = Taro.createIntersectionObserver().relativeToViewport({bottom:100})
  8. useEffect(()=>{
  9. observerObjBottom.observe('#a',(res)=>{
  10. console.log('a')
  11. })
  12. observerObjBottom.observe('#b',(res)=>{
  13. console.log('b')
  14. })
  15. observerObjBottom.observe('#c',(res)=>{
  16. console.log('c')
  17. })
  18. observerObjBottom.observe('#d',(res)=>{
  19. console.log('d')
  20. })
  21. observerObjBottom.observe('#e',(res)=>{
  22. console.log('e')
  23. })
  24. },[])
  25. return <View>
  26. <ScrollView scrollY style={{height:'100vh'}}>
  27. <View style={{height:'100vh',backgroundColor:'pink',width:rpxToPx(750)}} id="a"></View>
  28. <View style={{height:'100vh',backgroundColor:'blue',width:rpxToPx(750)}} id="b"></View>
  29. <View style={{height:'100vh',backgroundColor:'yellow',width:rpxToPx(750)}} id="c"></View>
  30. <View style={{height:'100vh',backgroundColor:'green',width:rpxToPx(750)}} id="d"></View>
  31. <View style={{height:'100vh',backgroundColor:'red',width:rpxToPx(750)}} id="e"></View>
  32. </ScrollView>
  33. {
  34. process.env.TARO_ENV == 'weapp' && <TabBar index={4} />
  35. }
  36. </View>
  37. }