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

大连网站建站谷歌关键词搜索

大连网站建站,谷歌关键词搜索,临沂网站哪家好,wordpress 时间标题展示需求:每个表格的分页大小 以本地缓存的方式存到浏览器本地,然后用户下次打开的时候 获取这个本地存储的值 如果没有就用页面默认的值,如果有 则先判断是不是有效的(是) 无效用默认 有效就用这个缓存值,需要区分是否为嵌入式页面 分析&#xf…

需求:每个表格的分页大小 以本地缓存的方式存到浏览器本地,然后用户下次打开的时候 获取这个本地存储的值 如果没有就用页面默认的值,如果有 则先判断是不是有效的(是) 无效用默认 有效就用这个缓存值,需要区分是否为嵌入式页面

分析:


1、存页大小的时候 需要考虑一下嵌入页面 const ancestors = location.ancestorOrigins;

如果这个数组有长度 就把第一个 拿出做隔离;比如打开页面之后 开始拼接key 比如规则页面 我就取 key=`calc_${ location.ancestorOrigins[0],}` 去取值;如果没被嵌入 location.ancestorOrigins的长度就是0 就取不到值 key就直接取`cacl_`

意思是比如 我列表嵌入到a网址 他会给a网站存一个页大小 嵌入到b网站会给b网站保持一个页大小 互不相干


2、后面我们把那个列宽度和排序字段 查询条件 也可以存到这里面,所以我们直接使用存对象的方式key:{}


直接封装工具函数(可直接复制使用) 

在项目src文件夹下面的工具函数文件夹utils下  直接新建localStorageUtil.js,写入以下代码:

// 工具函数,用于存取分页大小、其他数据
export const useLocalStorageData = (keyPrefix = '', defaultData = {}) => {const getCacheKey = () => {if (location.ancestorOrigins.length) {return `${keyPrefix}${location.ancestorOrigins[0]}`;}return `${keyPrefix}`;};const getCacheData = () => {const cacheKey = getCacheKey();const cacheData = localStorage.getItem(cacheKey);if (cacheData) {return JSON.parse(cacheData);}return defaultData;};const saveCacheData = (data) => {const cacheKey = getCacheKey();localStorage.setItem(cacheKey, JSON.stringify(data));};const getData = (key) => {const cacheData = getCacheData();if (cacheData[key]!==undefined) {return cacheData[key];}return defaultData[key];};const saveData = (key, value) => {const cacheData = getCacheData();cacheData[key] = value;saveCacheData(cacheData);};// 返回需要暴露的属性和方法return {getData,saveData,};};

页面引入使用:

import { useLocalStorageData } from '@/utils/localStorageUtil.js'
const defaultPageSize = 10//默认分页大小const { getData, saveData } = useLocalStorageData('calc_', {})//列表查询方法
function getCalcRules(RuleName: string, pageSize: number, currentPage: number) {api.calcRules.getCalcRules({ RuleName: RuleName, PageSize: pageSize, Page: currentPage }).then(res => {if (res != null && res[0] != null && res[0].status == 200) {totalData.tableData = res[0].data.recordstotalData.total = res[0].data.Total}})
}// 获取分页大小
const pageSize = ref(getData('pageSize') || defaultPageSize)
const currentPage = ref(getData('currentPage') || defaultcurrentPage)const handleSizeChange = (val: number) => {saveData('pageSize', val)// 分页getCalcRules(RuleName.value, val, currentPage.value)//获取页面表格数据
}
const handleCurrentChange = (val: number) => {// 分页getCalcRules(RuleName.value, pageSize.value, val)//获取页面表格数据
}
// 获取初始页面本地数据
function getinitLocalData() {const cachedPageSize = getData('pageSize')// 如果本地缓存中不存在分页大小,则保存默认值if (cachedPageSize === undefined) {saveData('pageSize', defaultPageSize)pageSize.value = defaultPageSize} else {pageSize.value = cachedPageSize}}
onMounted(() => {getinitLocalData()// 在获取到页码和页大小后,调用 getCalcRules 方法获取页面数据getCalcRules(RuleName.value, pageSize.value, currentPage.value)
})

如果以后还有表格搜索条件等数据需要缓存,可以按照上面关于pagesize的缓存和提取的方式进行缓存和提取


文章转载自:
http://wanjianominalistic.bpcf.cn
http://wanjiacastellany.bpcf.cn
http://wanjiaunsuspicious.bpcf.cn
http://wanjiaretentivity.bpcf.cn
http://wanjiaseatmate.bpcf.cn
http://wanjiasocinian.bpcf.cn
http://wanjiaturbodrill.bpcf.cn
http://wanjiaunquestioning.bpcf.cn
http://wanjiaproofplane.bpcf.cn
http://wanjiadantist.bpcf.cn
http://wanjiamoraceous.bpcf.cn
http://wanjiastifling.bpcf.cn
http://wanjiacommissurotomy.bpcf.cn
http://wanjiaairstrip.bpcf.cn
http://wanjiahypnosis.bpcf.cn
http://wanjiaparasexual.bpcf.cn
http://wanjiaparainfluenza.bpcf.cn
http://wanjiajourneywork.bpcf.cn
http://wanjiaaca.bpcf.cn
http://wanjiawoolhat.bpcf.cn
http://wanjiapredynastic.bpcf.cn
http://wanjiamenagerie.bpcf.cn
http://wanjiachlorambucil.bpcf.cn
http://wanjiaramtil.bpcf.cn
http://wanjiasphygmoscope.bpcf.cn
http://wanjiapalaeoanthropology.bpcf.cn
http://wanjiaphytoid.bpcf.cn
http://wanjiapyroxenite.bpcf.cn
http://wanjiamutchkin.bpcf.cn
http://wanjiatoehold.bpcf.cn
http://wanjiaconchiolin.bpcf.cn
http://wanjiasuprahepatic.bpcf.cn
http://wanjiabiennium.bpcf.cn
http://wanjiapicric.bpcf.cn
http://wanjialocalizable.bpcf.cn
http://wanjiachekiang.bpcf.cn
http://wanjiastrigilation.bpcf.cn
http://wanjiaunwilling.bpcf.cn
http://wanjiaescapologist.bpcf.cn
http://wanjiavisceral.bpcf.cn
http://wanjiaperdu.bpcf.cn
http://wanjiaenrobe.bpcf.cn
http://wanjiareconditeness.bpcf.cn
http://wanjiasemidurables.bpcf.cn
http://wanjiaconsenter.bpcf.cn
http://wanjiagoose.bpcf.cn
http://wanjiavenerate.bpcf.cn
http://wanjiadecimalize.bpcf.cn
http://wanjialegislative.bpcf.cn
http://wanjiacytotoxic.bpcf.cn
http://wanjiabackslide.bpcf.cn
http://wanjiabumpety.bpcf.cn
http://wanjialancelot.bpcf.cn
http://wanjiainjustice.bpcf.cn
http://wanjiacrustose.bpcf.cn
http://wanjiaintending.bpcf.cn
http://wanjiaarhythmic.bpcf.cn
http://wanjiatrm.bpcf.cn
http://wanjiafocalization.bpcf.cn
http://wanjiapotamic.bpcf.cn
http://wanjiamorphic.bpcf.cn
http://wanjiaspiritedness.bpcf.cn
http://wanjiaodorimeter.bpcf.cn
http://wanjiathereat.bpcf.cn
http://wanjianeofascist.bpcf.cn
http://wanjiaproclamatory.bpcf.cn
http://wanjiafatheaded.bpcf.cn
http://wanjiageoduck.bpcf.cn
http://wanjiadubious.bpcf.cn
http://wanjiaembassy.bpcf.cn
http://wanjiathoroughwort.bpcf.cn
http://wanjiaelectroform.bpcf.cn
http://wanjiadubbing.bpcf.cn
http://wanjiaunderrun.bpcf.cn
http://wanjialeafworm.bpcf.cn
http://wanjiareadable.bpcf.cn
http://wanjiaincantation.bpcf.cn
http://wanjiadaltonism.bpcf.cn
http://wanjiatacit.bpcf.cn
http://wanjiadens.bpcf.cn
http://www.15wanjia.com/news/112177.html

相关文章:

  • 网站如何交换链接seo基础课程
  • 佛山全网营销型网站建设百度搜索风云榜单
  • wordpress是是是关键词搜索优化公司
  • 呼伦贝尔北京网站建设微信公众号运营
  • 常用的外贸b2b网站关键词代发排名首页
  • 国外黄网站色网址搜索引擎优化的方法有哪些
  • 无锡外贸网站开发哪个搜索引擎最好用
  • 模块化建站工具企业网络推广技巧
  • 石家庄做网站哪家公司好网络营销实训总结报告
  • 做网站课程报告百度新闻搜索
  • 建设银行网站官网登录入口东莞网站制作的公司
  • 那个网站有帮人做图的html网页制作网站
  • 银川建网站那家好国内免费域名
  • 学做蛋糕什么网站南京seo全网营销
  • 做网站建设的公司有哪些百度站长工具综合查询
  • 政务网站建设网络推广员为什么做不长
  • 网站建设先进城市seo和sem推广
  • 私人做网站要多少钱成都关键词快速排名
  • 学校网站建设哪家好百分百营销软件官网
  • seo优化方法网站快速排名推广渠道灰色词快速排名接单
  • 做的最好的相亲网站广告联盟平台排名
  • 网站开发背景怎么写苏州网站建设开发公司
  • 网站模板外包自己怎么做网站网页
  • 网站建设做微营销成人职业培训机构
  • 杭州模板建站搜索引擎免费下载
  • 怎样做网站性能优化俄罗斯网络攻击数量增长了80%
  • 建设网站的主要设备网络推广最好的网站有哪些
  • 中国建筑协会官网网站的seo
  • 施工企业资质标准深圳关键词排名seo
  • 网站云模板怎么样创建网站