当前位置:网站首页>View lazy loading in applet
View lazy loading in applet
2022-06-09 15:08:00 【Don't stare at my name】
Preface
When writing small programs , There is a page that shows a lot of content , Pop up window city 6 individual , There are a lot of lists , therefore wxml There are many nodes , More than the applet suggests 1000 Below nodes .
This lazy load sample project code has been placed in github and Code cloud On
problem
This page with a lot of content is the first page of subcontracting , Before that, the development tools can run normally , So I didn't care about it . But last Saturday (2020 year 1 month 16 Japan ) after , There is a problem with the development tools !!! Enter the subcontracting page , The view takes half a day to render , But the event will be executed immediately ( The conclusion drawn from the click event and interface request ). Since the code has not changed compared with the previous day , And the phone is normal , So I doubted whether there was something wrong with the development tools at the first time , So I deleted the tool , And downloaded it again twice ( The latest stable version , The latest pre release version ), But it still doesn't work , Still this page of subcontracting , It can't be rendered . after , Open the performance monitoring panel of the mobile phone , I found that the value of rendering time is flashing all the time , But always stay in 0ms, It is certain that there is something wrong with the rendering of the applet . I also suspect that there are problems with the subcontracting page , Other subcontracting pages are found , No problem . then , Think about the experience score before , It has already prompted wxml Too many nodes , I annotated some code tentatively . good heavens , The development tools are normal immediately . Before identifying the problem , I didn't think about my code at the first time , Because after one day, the development tools will not run , This is really strange .
Optimize the code
First rendering , You don't need to render everything , So you can do lazy loading , Render when displayed , adopt wx:if To control whether .
Pass the test , The experience score after lazy loading is higher than that without lazy loading . Here are two contrast pictures :
Lazy loading is not used
Lazy loading is used
Project address :
Lazy loading principle
Small program passed setData Later data , And then put in wxml Will be rendered , But we can do this by setting wx:if Give Way , Node not displayed , You won't render . When the scroll hits the bottom , Through one more Tag value To judge the subsequent rendering .
In this example, the following view is rendered only after touching the bottom , When you click the category on the left , Also do rendering .
such as : Initially, only the first set of data is rendered , When I clicked the fourth category , The second one , Third , The data of the fourth one is displayed . This is also through this Tag value To judge .
Sketch Map :
边栏推荐
- GreatSQL如何做中国广受欢迎的开源数据库
- 验证回文串
- Applet turntable lottery assembly
- Excel上使用VBA的WebBrowser控件实现单点登录(SSO)
- 497. 非重叠矩形中的随机点
- Hongmeng porting i.mx6ull (11) storage device driver (based on imx6ull)
- Taoist friend, what have you done with redis?
- ONES 冯斌:从工程师到CTO,与不确定性和信息不完备为伴|ONES Talk
- List used by icomponent of unity dots
- 中国加密艺术师孟晓峰参加意大利举办的“液态合金”元宇宙画展
猜你喜欢

国货彩妆,败走618

不要假装怀念Kindle

程序员高考卷曝光,你能得多少分?
![[paper] cascade rpn: delving into high quality region proposal network with adaptive revolution](/img/bc/675a4cd11ceb69cdc5be1864003be0.png)
[paper] cascade rpn: delving into high quality region proposal network with adaptive revolution

Will quic become a disruptor of Internet transmission?
![[云原生]Kubernetes可视化界面WEBUI Kubernetes Dashboard](/img/25/9ec90f660b290823c36c1fe5a4c69e.jpg)
[云原生]Kubernetes可视化界面WEBUI Kubernetes Dashboard

@Enablefeignclients annotation source code analysis

Hongmeng porting i.mx6ull (VI) kconfig_ GCC_ Mkefile

In June, 2022, China Database ranking: tidb made a comeback to win the crown, and Dameng was dormant and won the flowers in May

最成功也最差劲的CEO去世,索尼还是走在他的老路上
随机推荐
860. 柠檬水找零
你好,欢迎访问我的博客
After 4 years of experience, I have interviewed 20K test posts. I can't even master basic skills. It's better to recruit fresh students
为什么 SQL 语句使用了索引,但却还是慢查询?
BAT和FAANG的时代翻篇儿了,谁来接棒?
【论文】Cascade R-CNN: Delving into High Quality Object Detection
2022年6月中国数据库排行榜:TiDB卷土重来摘桂冠,达梦蛰伏五月夺探花
单调队列优化Dp例题
名片微信小程序错误版本2
JS实现复制内容到剪贴板的方法
Applet turntable lottery assembly
网上开户渠道靠谱吗?安全吗?
QUIC会成为互联网传输的颠覆者吗?
China UnionPay (Cloud Computing) fixed-point services: lingqueyun, daocloud, Youyun and Boyun won the bid (Development); Shenzhou information, Tencent cloud and Xinhua three standards (transportation
GaussDB(DWS)功能及配套工具丨【这次高斯不是数学家】
Rest API中PUT 与 PATCH 使用区别及幂等性分析
从版权到资产 NFT有多不安全?
v-lazy
文字广播图的错误代码
中金 | 数智中国之二:数据库商业市场五问五答