react hook页面滚动到某一高度,显示回到顶部按钮
回到顶部组件:
import React, { useEffect, useState } from 'react';
import { ArrowUpOutlined } from '@ant-design/icons';
import PropTypes from 'prop-types';
function ToTop(props) {
const { showPhone } = props;
const [show, switchShow] = useState(false);
useEffect(() => {
const handleScroll = e => {
if (showPhone) { //是否在手机端显示
if (window.innerWidth < 600) { //判断是否手机端
if (window.scrollY > window.innerHeight) { //当滚动超过一屏的时候,显示
switchSho
共有 0 条评论