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

uniapp 自定义加载组件,全屏加载,局部加载 (微信小程序)

效果图

全屏加载  页面加载使用

局部加载   列表加载里面使用

使用gif

html 

<template><view><view class="" v-if="type=='FullScreen'"><view class="loading" v-if="show"><view class=""><image class="loadingicon"src="../../static/all/loading.gif"mode="aspectFit"></image><view style="color:#999;width: 100%;">加载中</view></view></view></view><view class="" v-if="type=='adaptive'"><view class="loading_adaptive" v-if="show"><view class=""><image class="loadingicon"src="../../static/all/loading.gif"mode="aspectFit"></image><view style="color:#999;width: 100%;">加载中</view></view></view></view></view>
</template>

css

	.loading {width: 100vw;height: 100vh;background: #fff;position: fixed;top: 0;left: 0;z-index: 999999;text-align: center;box-sizing: border-box;display: flex;justify-content: center;align-items: center;flex-wrap: wrap;.loadingicon {width: 100rpx;height: 100rpx;}}.loading_adaptive {width: 100%;height: 500rpx;z-index: 999999;text-align: center;box-sizing: border-box;display: flex;justify-content: center;align-items: center;flex-wrap: wrap;.loadingicon {width: 100rpx;height: 100rpx;}}

js

	export default {name: "loading",data() {return {};},props: {show: {default: false,type: Boolean},type: {default: 'FullScreen', //全屏使用或者自适应使用type: String}},watch: {show: {handler(newData, oldData) {console.log(newData, '新值');console.log(oldData, '老值');},immediate: true,deep: true}}}

挂载全局或页面引入使用

需要放在最外层view

		<loading :show="loadingshow"></loading>

js

loadingshow: true,//在生命周期 例如:onload 或者 接口请求里面使用
//时间可以自定义
//第一种方式在生命周期中使用:setTimeout(() => {that.loadingshow = false;}, 200)//第二种方式在接口里面使用:需要展示数据的接口({page: this.page,limit: this.limit}).then(ress => {//数据请求完毕再关闭加载if(res.code==1){that.loadingshow = false;}})

http://www.lryc.cn/news/487837.html

相关文章:

  • STM32完全学习——系统时钟设置
  • Github 2024-11-16Rust开源项目日报 Top10
  • CH03_反射
  • vue2侧边导航栏路由
  • core 不可变类型 线程安全 record
  • linux之调度管理(8)-SMP cpu 的 psci启动
  • review-消息中间件MQ
  • leetcode400第N位数字
  • 前端网页开发学习(HTML+CSS+JS)有这一篇就够!
  • CSS遮罩:mask
  • Swift闭包的本质
  • 时代变迁对传统机器人等方向课程的巨大撕裂
  • 【算法设计与分析实训】第1关:求序列的最大字段和
  • 【澜舟科技-注册/登录安全分析报告】
  • 【读书笔记-《网络是怎样连接的》- 7】Chapter3_2 路由器
  • Android Activity 基础接口知识和常见问题
  • 利用python 检测当前目录下的所有PDF 并转化为png 格式
  • 解决 Spring Boot 中 `Ambiguous mapping. Cannot map ‘xxxController‘ method` 错误
  • C++ 函数返回值优化
  • c++源码阅读__ThreadPool__正文阅读
  • 关于ES的查询
  • 数据结构初识
  • 保存数据到Oracle时报错ORA-17004: 列类型无效: 1111
  • Excel——宏教程(1)
  • 论文浅尝 | MindMap:知识图谱提示激发大型语言模型中的思维图(ACL2024)
  • 第6章:TDengine 标签索引和删除数据
  • 【微软:多模态基础模型】(5)多模态大模型:通过LLM训练
  • 海外带云仓多语言商城源码,多语言多商家云仓一键代发商城
  • android:taskAffinity 对Activity退出时跳转的影响
  • Apache Dolphinscheduler数据质量源码分析