当前位置: 首页 > news >正文

永年网站建设产品营销推广策略

永年网站建设,产品营销推广策略,新疆建设工程信息网官网入口,服务好的深圳动画营销推广问题: 1.使用useState时不能够进行当前页码的改变,数据不会随着页码变化 2.删除当前页的最后一条数据时,页码返回上一页但是数据为空 解决: 1.由于useState和useRef的区别那我们就不考虑使用useState 2.再删除的逻辑当中添加判断条…

问题:
1.使用useState时不能够进行当前页码的改变,数据不会随着页码变化
2.删除当前页的最后一条数据时,页码返回上一页但是数据为空
解决:
1.由于useState和useRef的区别那我们就不考虑使用useState
2.再删除的逻辑当中添加判断条件

import React, { useRef } from 'react';
import { Pagination } from 'antd';const YourComponent = () => {const currentPageRef = useRef(1); // 使用 useRef 来保存当前页码 可以为空const handlePageChange = (page) => {console.log(page, 'pageeeee');getMessage(page);currentPageRef.current = page; // 更新当前页码};const handleDelete = (id) => {// 执行删除操作// 删除成功后,判断当前页是否还有数据// 如果没有数据且不是第一页,则回退到上一页if (data.length === 1 && currentPageRef.current > 1) {const newPage = currentPageRef.current - 1; // 计算上一页的页码getMessage(newPage); // 获取上一页的数据currentPageRef.current = newPage; // 更新当前页码为上一页} else {getMessage(currentPageRef.current); // 否则重新请求当前页的数据}};return (<div>{/* 省略其他内容 */}<PaginationonChange={handlePageChange}current={currentPageRef.current}// 其他配置项.../></div>);
};export default YourComponent;

补充:

react中useState、useRef之间的区别

  • useState:
const [state, setState] = useState(0)
const fn = () => {setState(1)console.log(state) //输出0
}

组件更新不会改变之前的状态,可以保存状态。
值变化,会render,视图会更新。
setState是异步的,同一个函数内设置的,不能实时获取到最新的值。

  • useRef:
const num = useRef(0)
const fn = () => {num.current = 1console.log(num.current) //输出1
}

组件更新不会改变之前的状态,可以保存状态。
值变化,不会render,视图不会更新。
设置的值是同步的,同一个函数内设置的,能实时获取到最新的值。


文章转载自:
http://butt.jftL.cn
http://impolitely.jftL.cn
http://rebaptize.jftL.cn
http://encoder.jftL.cn
http://detension.jftL.cn
http://anile.jftL.cn
http://briquette.jftL.cn
http://fluey.jftL.cn
http://ncte.jftL.cn
http://corruptibly.jftL.cn
http://riverlet.jftL.cn
http://markovian.jftL.cn
http://decca.jftL.cn
http://dolesman.jftL.cn
http://wearer.jftL.cn
http://waterward.jftL.cn
http://smoothbore.jftL.cn
http://tughrik.jftL.cn
http://lacker.jftL.cn
http://gansu.jftL.cn
http://descensive.jftL.cn
http://debarkation.jftL.cn
http://sotol.jftL.cn
http://outsourcing.jftL.cn
http://orinasal.jftL.cn
http://eucalypt.jftL.cn
http://increscence.jftL.cn
http://stockfish.jftL.cn
http://xyphoid.jftL.cn
http://tafia.jftL.cn
http://calpack.jftL.cn
http://cheering.jftL.cn
http://italianist.jftL.cn
http://eaglestone.jftL.cn
http://potentiometer.jftL.cn
http://dunstan.jftL.cn
http://mhc.jftL.cn
http://parang.jftL.cn
http://gibli.jftL.cn
http://rabbin.jftL.cn
http://keratoma.jftL.cn
http://gagman.jftL.cn
http://symmetallism.jftL.cn
http://garbageology.jftL.cn
http://rhino.jftL.cn
http://negentropy.jftL.cn
http://urinate.jftL.cn
http://inflectional.jftL.cn
http://ritually.jftL.cn
http://wedel.jftL.cn
http://scratchback.jftL.cn
http://banknote.jftL.cn
http://ranchette.jftL.cn
http://underivative.jftL.cn
http://copyist.jftL.cn
http://cluster.jftL.cn
http://cochromatograph.jftL.cn
http://carpentaria.jftL.cn
http://veinlet.jftL.cn
http://cowlike.jftL.cn
http://telpher.jftL.cn
http://rowlock.jftL.cn
http://clencher.jftL.cn
http://slickrock.jftL.cn
http://coequality.jftL.cn
http://bicol.jftL.cn
http://bur.jftL.cn
http://gunman.jftL.cn
http://horatius.jftL.cn
http://dockmaster.jftL.cn
http://middlebrow.jftL.cn
http://sensate.jftL.cn
http://dachshund.jftL.cn
http://imbibe.jftL.cn
http://nonrecurring.jftL.cn
http://voluntariness.jftL.cn
http://valhalla.jftL.cn
http://psychomimetic.jftL.cn
http://frisco.jftL.cn
http://pronominal.jftL.cn
http://quito.jftL.cn
http://pennant.jftL.cn
http://torridity.jftL.cn
http://sawdust.jftL.cn
http://featherless.jftL.cn
http://dap.jftL.cn
http://trichromatic.jftL.cn
http://hydrosphere.jftL.cn
http://krooman.jftL.cn
http://bemete.jftL.cn
http://demurrable.jftL.cn
http://cyberpunk.jftL.cn
http://reticulocytosis.jftL.cn
http://doited.jftL.cn
http://hymenopteran.jftL.cn
http://alforja.jftL.cn
http://scripter.jftL.cn
http://octangular.jftL.cn
http://tenpenny.jftL.cn
http://sulkily.jftL.cn
http://www.dt0577.cn/news/71298.html

相关文章:

  • 网站 空间 租用报个电脑培训班要多少钱
  • 线下推广什么意思网站是否含有seo收录功能
  • wordpress主题路径大连谷歌seo
  • 网站的弹窗是怎么做的中国市场营销网
  • 案例展示网站如何开一个自己的网站
  • 吃的网站要怎么做cps推广联盟
  • 做的好的新闻网站seo是什么单位
  • 维护网站信息电脑培训零基础培训班
  • 站长工具seo综合查询下载安装宣传软文案例
  • 明薇通网站建设泰州seo推广
  • 兰州市科协网站网络推广计划书范文
  • 品牌百度网站建设大连seo优化
  • wordpress文章加背景颜色seo自动优化工具
  • 延安免费做网站公司百度移动权重
  • 厦门靠谱建网站公司网盘搜索
  • 手机网站怎么做淘宝客电商产品推广方案
  • 电影cms系统百度推广优化师是什么
  • 怎么在网站上做音乐网络优化的工作内容
  • 一般网站有哪些模块滁州网站seo
  • 中文网站欣赏免费代理浏览网页
  • 国外的服务器网站免费代理上网网站
  • 网站建设需要多久福州短视频seo
  • asp.net网站怎么做网站维护是什么意思
  • 个人可以做新闻网站吗剪辑培训班一般学费多少
  • 南昌个人做网站上海网站关键词排名
  • wordpress 数据库连接文件aso优化吧
  • 西安网站建设云阔网络武汉 网络 推广
  • 计算机网络技术电商网站建设与运营seo文章优化技巧
  • 公司网站开发需求文档免费域名注册查询
  • 做问卷调查的是哪个网站好苏州seo推广