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

uniapp实战 —— 骨架屏

1. 自动生成骨架屏代码

在微信开发者工具中,预览界面点击生成骨架屏

在这里插入图片描述
在这里插入图片描述
确定后,会自动打开骨架屏代码文件 pages\index\index.skeleton.wxml

2. 将骨架屏代码转换为vue文件

  • 在项目中新建文件 src\pages\index\components\skeleton.vue

  • 将pages\index\index.skeleton.wxml中的代码复制到 skeleton.vue 中

  • 删除所有的注释和无接口访问的部分(如顶部的导航栏),如下图所示,通过 is 属性可以轻松辨别出各个组件对应的骨架屏代码。

在这里插入图片描述

  • scroll-view 标签也删除,只留接口更新内容的静态骨架屏代码
  • 在skeleton.vue的 template 标签外新建 style 标签
  • 将微信开发者工具生成的骨架屏相关的css代码 (pages\index\index.skeleton.wxss中)复制到项目文件 skeleton.vue的 style 标签中,删除所有的注释

最终范例代码如下:
src\pages\index\components\skeleton.vue

<template name="skeleton"><view is="components/SUI_Swiper"><view class="carousel Swiper--carousel"><swiper interval="3000" circular="true" current="0" autoplay="false"><swiper-itemstyle="position: absolute;width: 100%;height: 100%;transform: translate(0%, 0px) translateZ(0px);"><navigator class="navigator Swiper--navigator" hover-class="none" open-type="navigate"><image class="image Swiper--image sk-image" mode="aspectFill"></image></navigator></swiper-item></swiper><view class="indicator Swiper--indicator"><text class="dot Swiper--dot active Swiper--active"></text><text class="dot Swiper--dot"></text><text class="dot Swiper--dot"></text><text class="dot Swiper--dot"></text><text class="dot Swiper--dot"></text></view></view></view><view is="pages/index/components/CategoryPanel"><view class="category CategoryPanel--category"><navigator class="category-item CategoryPanel--category-item" hover-class="none"><image class="icon CategoryPanel--icon sk-image"></image><text class="text CategoryPanel--text sk-transparent sk-text-14-2857-543 sk-text">居家</text></navigator><navigator class="category-item CategoryPanel--category-item" hover-class="none"><image class="icon CategoryPanel--icon sk-image"></image><text class="text CategoryPanel--text sk-transparent sk-text-14-2857-231 sk-text">锦鲤</text></navigator><navigator class="category-item CategoryPanel--category-item" hover-class="none"><image class="icon CategoryPanel--icon sk-image"></image><text class="text CategoryPanel--text sk-transparent sk-text-14-2857-820 sk-text">服饰</text></navigator><navigator class="category-item CategoryPanel--category-item" hover-class="none"><image class="icon CategoryPanel--icon sk-image"></image><text class="text CategoryPanel--text sk-transparent sk-text-14-2857-396 sk-text">母婴</text></navigator><navigator class="category-item CategoryPanel--category-item" hover-class="none"><image class="icon CategoryPanel--icon sk-image"></image><text class="text CategoryPanel--text sk-transparent sk-text-14-2857-960 sk-text">个护</text></navigator><navigator class="category-item CategoryPanel--category-item" hover-class="none"><image class="icon CategoryPanel--icon sk-image"></image><text class="text CategoryPanel--text sk-transparent sk-text-14-2857-548 sk-text">严选</text></navigator><navigator class="category-item CategoryPanel--category-item" hover-class="none"><image class="icon CategoryPanel--icon sk-image"></image><text class="text CategoryPanel--text sk-transparent sk-text-14-2857-816 sk-text">数码</text></navigator><navigator class="category-item CategoryPanel--category-item" hover-class="none"><image class="icon CategoryPanel--icon sk-image"></image><text class="text CategoryPanel--text sk-transparent sk-text-14-2857-7 sk-text">运动</text></navigator><navigator class="category-item CategoryPanel--category-item" hover-class="none"><image class="icon CategoryPanel--icon sk-image"></image><text class="text CategoryPanel--text sk-transparent sk-text-14-2857-68 sk-text">杂项</text></navigator><navigator class="category-item CategoryPanel--category-item" hover-class="none"><image class="icon CategoryPanel--icon sk-image"></image><text class="text CategoryPanel--text sk-transparent sk-text-14-2857-539 sk-text">品牌</text></navigator></view></view><view is="components/SUI_Guess" class="r"><view class="caption Guess--caption"><textclass="text Guess--text sk-transparent sk-text-0-0000-556 sk-text sk-pseudo sk-pseudo-circle">猜你喜欢</text></view><view class="guess Guess--guess"><navigator class="guess-item Guess--guess-item"><image class="image Guess--image sk-image" mode="aspectFill"></image><view class="name Guess--name sk-transparent sk-text-14-2857-479 sk-text">极光限定 珠光蓝珐琅锅</view></navigator><navigator class="guess-item Guess--guess-item"><image class="image Guess--image sk-image" mode="aspectFill"></image><view class="name Guess--name sk-transparent sk-text-14-2857-647 sk-text">法式清新,长袖格纹连衣裙/衬衫110-160cm</view></navigator></view></view>
</template><style>
.sk-transparent {color: transparent !important;
}
.sk-text-14-2857-484 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 43.1159rpx;position: relative !important;
}
.sk-text {background-origin: content-box !important;background-clip: content-box !important;background-color: transparent !important;color: transparent !important;background-repeat: repeat-y !important;
}
.sk-text-3-3333-275 {background-image: linear-gradient(transparent 3.3333%,#eeeeee 0%,#eeeeee 96.6667%,transparent 0%) !important;background-size: 100% 27.1739rpx;position: relative !important;
}
.sk-text-14-2857-543 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-14-2857-231 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-14-2857-820 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-14-2857-396 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-14-2857-960 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-14-2857-548 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-14-2857-816 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-14-2857-7 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-14-2857-68 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-14-2857-539 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-0-0000-556 {background-image: linear-gradient(transparent 0%,#eeeeee 0%,#eeeeee 100%,transparent 0%) !important;background-size: 100% 30.7971rpx;position: relative !important;
}
.sk-text-14-2857-479 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-text-14-2857-647 {background-image: linear-gradient(transparent 14.2857%,#eeeeee 0%,#eeeeee 85.7143%,transparent 0%) !important;background-size: 100% 35.5072rpx;position: relative !important;
}
.sk-image {background: #efefef !important;
}
.sk-pseudo::before,
.sk-pseudo::after {background: #efefef !important;background-image: none !important;color: transparent !important;border-color: transparent !important;
}
.sk-pseudo-rect::before,
.sk-pseudo-rect::after {border-radius: 0 !important;
}
.sk-pseudo-circle::before,
.sk-pseudo-circle::after {border-radius: 50% !important;
}
.sk-container {position: absolute;left: 0;top: 0;width: 100%;height: 100%;overflow: hidden;background-color: transparent;
}
</style>

3. 导入并使用骨架屏vue文件

src\pages\index\index.vue

import Skeleton from './components/skeleton.vue'

在这里插入图片描述

// 默认显示骨架屏
const loading = ref(true)
onLoad(async () => {// 加载数据--所有接口同时开始刷新,直到耗时最长的接口返回数据await Promise.all([getSwiperInfo(), getCategoryInfo()])// 加载数据成功后,隐藏骨架屏,显示数据loading.value = false
})

相关文章:

uniapp实战 —— 骨架屏

1. 自动生成骨架屏代码 在微信开发者工具中&#xff0c;预览界面点击生成骨架屏 确定后&#xff0c;会自动打开骨架屏代码文件 pages\index\index.skeleton.wxml 2. 将骨架屏代码转换为vue文件 在项目中新建文件 src\pages\index\components\skeleton.vue 将pages\index\index…...

【数据仓库-10】-- 数据仓库、数据湖和湖仓一体对比

目录 1 数据仓库与数据库的对比 2 数据湖与数据仓库的对比 3 数据仓库、数据湖和湖仓一体...

单臂路由与三层交换机

单臂路由 划分VLAN后同一VLAN的计算机属于同一个广播域&#xff0c;同一VLAN的计算机之间的通信是不成问题的。然而&#xff0c;处于不同VLAN的计算机即使是在同一交换机上&#xff0c;它们之间的通信也必须使用路由器。 图&#xff08;a&#xff09;是一种实现VLAN间路由的方…...

免费的数据采集软件,最新免费的几款数据采集软件【2024】

在当今数字化时代&#xff0c;数据是企业决策和业务发展的关键。而如何高效获取数据成为许多企业和研究机构的关注焦点。本文将深入探讨数据采集软件的种类。帮助大家选择最适合自己需求的数据采集工具。 数据采集软件种类 在众多数据采集软件中&#xff0c;有一类强大而多样…...

nodejs微信小程序+python+PHP北京地铁票务APP-计算机毕业设计推荐 -安卓

目 录 摘 要 I ABSTRACT II 目 录 II 第1章 绪论 1 1.1背景及意义 1 1.2 国内外研究概况 1 1.3 研究的内容 1 第2章 相关技术 3 2.1 nodejs简介 4 2.2 express框架介绍 6 2.4 MySQL数据库 4 第3章 系统分析 5 3.1 需求分析 5 3.2 系统可行性分析 5 3.2.1技术可行性&#xff1a;…...

zabbix 进阶

zabbix的字段发现机制&#xff1a; zabbix客户端主动和服务端联系&#xff0c;将自己的地址和端口发送服务端实现字段添加监控主机。 客户端是主动一方。 缺点&#xff1a;自定义网段中主机数量太多&#xff0c;登记耗时会很久&#xff0c;而且这个自动发现机制不是很稳定。…...

【性能测试】Jmeter 配置元件(一):计数器

Jmeter 配置元件&#xff08;一&#xff09;&#xff1a;计数器 在 Jmeter 中&#xff0c;通过函数 ${__counter(,)} 可以实现每次加 1 1 1 的计数效果。但如果步长不为 1 1 1&#xff0c;则要利用到我们的计数器。 函数作用${__counter(,)}计数器&#xff0c;每次加 1${__d…...

使用Dockerfile Maven Plugin 将Docker镜像Push到AWS ECR (Elastic Container Registry)

文章目录 小结问题解决AWS ECR (Elastic Container Registry)的登录问题 pull access denied for jdk, repository does not exist问题 Could not acquire image ID or digest following builddockerfile-maven-plugin 使用 参考 小结 本文记录使用Dockerfile Maven Plugin 将…...

ubuntu 20.04.6 server 服务器 下载与安装(配置静态IP)

下载地址&#xff1a;https://releases.ubuntu.com/20.04.6/ubuntu-20.04.6-live-server-amd64.iso 第一步&#xff1a; 准备U盘&#xff0c;使用软碟通将下载好的镜像写入到U盘中 软碟通网址&#xff1a;https://www.cn.ultraiso.net/xiazai.html 点击&#xff1a;文件 ->…...

[Linux] Apache的配置与运用

一、web虚拟主机的构台服务器上运行多个网站&#xff0c;每个网站实际上并不独立占用整个服务器&#xff0c;因此称为"虚拟"虚拟主机的虚拟主机服务可以让您充分利用服务器的硬件资源&#xff0c;大大降低了建立和运营网站的成本 Httpd服务使构建虚拟主机服务器变得容…...

PHP基础 - 注释变量

一. 语言开始标识 在PHP中,文件的开头需要使用语言开始标识来指定该文件是PHP代码。标识通常为"<?php",也可以是"<?",但建议使用"<?php"以确保代码的兼容性和可读性。 <?php // PHP代码从这里开始写 二. PHP注释 注释是用…...

【图论笔记】克鲁斯卡尔算法(Kruskal)求最小生成树

【图论笔记】克鲁斯卡尔算法&#xff08;Kruskal&#xff09;求最小生成树 适用于 克鲁斯卡尔适合用来求边比较稀疏的图的最小生成树 简记&#xff1a; 将边按照升序排序&#xff0c;选取n-1条边&#xff0c;连通n个顶点。 添加一条边的时候&#xff0c;如何判断能不能添加…...

oops-framework框架 之 多语言设置文本、精灵和骨骼动画

引擎&#xff1a; CocosCreator 3.8.0 环境&#xff1a; Mac Gitee: oops-plugin-excel-to-json 注&#xff1a; 作者dgflash的oops-framework框架QQ群&#xff1a; 628575875 简介 作者dgflash在oops-framework的框架中提供了多语言&#xff0c;主要用于对文本、图片、骨骼动…...

阿里云SLB的使用总结

一、什么是SLB 实现k8s的服务service的一种推荐方式&#xff0c;也是服务上云后&#xff0c;替代LVS的一个必选产品。 那么它有什么作用呢&#xff1f; 1、负载均衡&#xff0c;是它与生俱来的。可以配置多个服务器组&#xff1a;包括虚拟服务器组、默认服务器组、主备服务器…...

Python-pdf工具自制(合并、拆分、删除)

pdf工具&#xff0c;之前写的合并工具有点麻烦&#xff0c;使用PyQt5库重写合并拆分和删除指定页面的程序 实现如图&#xff1a; 代码&#xff1a; import sysimport osfrom PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget, QFileDia…...

23.12.9 《CLR via C#》 笔记7

第九章 参数 可选参数和命名参数 可选参数&#xff1a;在方法声明中为参数指定默认值&#xff0c;在调用方法时&#xff0c;如果不提供相应可选参数的值&#xff0c;将会使用默认值命名参数&#xff1a;在调用方法时通过指定参数名称来传递参数值&#xff0c;而不是按照参数在方…...

input、el-input输入框输入规则

一、input 只能输入框只能输入正整数&#xff0c;输入同时禁止了以0开始的数字输入&#xff0c;防止被转化为其他进制的数值。 <!-- 不能输入零时--> <input typetext οninput"valuevalue.replace(/^(0)|[^\d]/g,)"><!-- 能输入零时--> <inp…...

Qt优秀开源项目之十九:跨平台记事本Notes

官网&#xff1a;https://www.get-notes.com github&#xff1a;https://github.com/nuttyartist/notes 一.特性 1.完全基于Qt和C 2.完全开源和跨平台&#xff08;Linux、macOS、Windows&#xff09; 3.运行速度快&#xff0c;界面美如画 4.支持Markdown 5.支持使用嵌套文件夹…...

[足式机器人]Part4 南科大高等机器人控制课 Ch03 Operator View of Rigid-Body Transformation

本文仅供学习使用 本文参考&#xff1a; B站&#xff1a;CLEAR_LAB 笔者带更新-运动学 课程主讲教师&#xff1a; Prof. Wei Zhang 南科大高等机器人控制课 Ch03 Operator View of Rigid-Body Transformation 1. Rotation Operation via Differential Equation1.1 Skew Symmetr…...

SpringBoot项目静态资源默认访问目录

SpringBoot项目&#xff1a;静态资源默认访问目录 参考博客&#xff1a;https://blog.csdn.net/weixin_43808717/article/details/118281904...

厂房钢结构工程:从设计、制造到安装验收的关键要点全解析

一、什么是厂房钢结构工程&#xff0c;为什么越来越常见&#xff1f;厂房钢结构工程&#xff0c;简单说&#xff0c;就是以钢柱、钢梁、檩条、支撑体系、屋面系统和围护系统为主体&#xff0c;完成工业厂房、仓储车间、物流中心、生产车间及配套功能区建设的一类工程。相比传统…...

Syncthing中继服务器搭建全攻略:解决公共服务器速度慢的问题(附详细配置步骤)

Syncthing中继服务器搭建实战&#xff1a;突破公共服务器速度瓶颈 周末团队协作时&#xff0c;Syncthing公共中继服务器的龟速让人抓狂——跨国传输一个设计稿居然要两小时。这促使我探索自建中继服务器的方案&#xff0c;实测将同步速度提升8倍。本文将分享从服务器选型到客户…...

突破网页资源提取困境:猫抓工具解密流媒体下载全攻略

突破网页资源提取困境&#xff1a;猫抓工具解密流媒体下载全攻略 【免费下载链接】cat-catch 猫抓 浏览器资源嗅探扩展 / cat-catch Browser Resource Sniffing Extension 项目地址: https://gitcode.com/GitHub_Trending/ca/cat-catch 你是否曾为无法保存在线课程视频而…...

音乐版权检测新方案:CCMusic模型与MySQL数据库集成

音乐版权检测新方案&#xff1a;CCMusic模型与MySQL数据库集成 用AI技术解决音乐版权保护难题&#xff0c;让每一首作品都能得到应有的尊重 1. 引言&#xff1a;音乐版权保护的现实挑战 音乐创作者们经常面临这样的困境&#xff1a;自己的作品在各大平台被无授权使用&#xff…...

Tencent Hunyuan3D-1.0学术合作机会:腾讯混元团队的研究方向与合作模式

Tencent Hunyuan3D-1.0学术合作机会&#xff1a;腾讯混元团队的研究方向与合作模式 【免费下载链接】Hunyuan3D-1 腾讯开源的Hunyuan3D-1项目&#xff0c;创新提出两阶段3D生成方法&#xff0c;实现快速、高质量的文本到3D和图像到3D转换&#xff0c;融合Hunyuan-DiT模型&#…...

遥感小白别慌!ENVI 5.6 基础操作保姆级教程:从打开文件到剖面图显示,一篇搞定

遥感新手实战指南&#xff1a;ENVI 5.6 从零到剖面分析的完整工作流 第一次打开ENVI时&#xff0c;那个布满英文按钮的界面和密密麻麻的菜单栏&#xff0c;是不是让你瞬间想起了大学时被专业课支配的恐惧&#xff1f;别担心&#xff0c;三年前的我也是这样——面对一幅Landsat…...

Z-Image-Turbo模型在智能车领域的应用:仿真场景图像生成

Z-Image-Turbo模型在智能车领域的应用&#xff1a;仿真场景图像生成 最近和几个做自动驾驶算法的朋友聊天&#xff0c;他们都在为一个问题头疼&#xff1a;测试数据不够用。特别是那些罕见的极端场景&#xff0c;比如暴雨天、浓雾夜&#xff0c;或者刺眼的逆光路况&#xff0c…...

零基础如何用罗技鼠标宏实现绝地求生自动压枪?高效配置指南

零基础如何用罗技鼠标宏实现绝地求生自动压枪&#xff1f;高效配置指南 【免费下载链接】logitech-pubg PUBG no recoil script for Logitech gaming mouse / 绝地求生 罗技 鼠标宏 项目地址: https://gitcode.com/gh_mirrors/lo/logitech-pubg 你是否在《绝地求生》中因…...

从MAX30102项目实战出发:解决Keil5编译STM32时ARMCLANG和头文件缺失的连环坑

从MAX30102项目实战解析Keil5编译STM32的深度排坑指南 当你在深夜调试MAX30102血氧传感器时&#xff0c;Keil5突然弹出一连串编译器报错——这种经历对STM32开发者来说绝不陌生。本文将以真实项目为背景&#xff0c;拆解那些官方文档从未提及的编译陷阱。不同于常规操作手册&a…...

G-Helper终极指南:如何用轻量级工具优化华硕笔记本性能与电池健康

G-Helper终极指南&#xff1a;如何用轻量级工具优化华硕笔记本性能与电池健康 【免费下载链接】g-helper Lightweight, open-source control tool for ASUS laptops and ROG Ally. Manage performance modes, fans, GPU, battery, and RGB lighting across Zephyrus, Flow, TUF…...