Vue3 Loading组件的封装(通用组件的使用) 引入直接使用

支持自定义样式 的使用 图片的使用 

uniapp loading加载动画提示

组件名:uaLoading 代码块: <ua-loading>

uaLoading基于uniapp vue3自定义loading加载提示组件。支持自定义加载图标、文字水平/垂直排列、包裹内容块、全屏提示等功能。

引入方式

本组件符合easycom规范,只需将本组件放在components目录,在页面template中即可直接使用。

基本用法

示例

  • 基础用法
<script setup>
	import { ref } from 'vue'
	
	const loaded = ref(true)
	const loading = ref(true)
	const loadingfull = ref(false)
	const loadingstyle = ref(false)
	const loadingstyle2 = ref(false)
	
	const handleOpen = () => {
		console.log('opened!')
	}
	const handleClose = () => {
		console.log('closed!')
	}
</script>
<ua-loading v-model="loaded" background="rgba(0,0,0,.75)" spinner="ve-icon-loading" fullscreen="false">
	<template #text><div>加载中...</div></template>
</ua-loading>
<ua-loading v-model="loaded" text="Loading..." background="rgba(0,0,0,.75)" fullscreen="false" />
<ua-loading v-model="loaded" text="加载中" size="16px" mode="horizontal" background="rgba(0,0,0,.5)" fullscreen="false" />
  • 自定义全屏loading
<ua-loading
	v-model="loadingfull"
	text="加载中"
	time="3"
	size="50px"
	background="rgba(5,50,10,.9)"
	fullscreen="true"
	@open="handleOpen"
	@close="handleClose"
/>
  • 自定义loading动画样式
<ua-loading v-model="loadingstyle" background="rgba(0,0,0,.75)" shadeClose>
	<template #spinner>
		<span class="custom-loading">
			<em></em><em></em><em></em><em></em><em></em>
		</span>
	</template>
	<template #text><div style="color: greenyellow;">加载中...</div></template>
</ua-loading>
.custom-loading {display: inline-flex; align-items: flex-end; gap: 5px; min-height: 45px;}
.custom-loading em {
    background: #ff007f; border-radius: 6px; display: inline-block; height: 100%; width: 5px;
    animation: animHeart 1s linear infinite;
}
@keyframes animHeart {
    0%,100% {height: 15px; background: #ff007f;}
    50% {height: 45px; background: #55ff00;}
}
.custom-loading em:nth-child(2) {animation-delay: .2s;}
.custom-loading em:nth-child(3) {animation-delay: .4s;}
.custom-loading em:nth-child(4) {animation-delay: .6s;}
.custom-loading em:nth-child(5) {animation-delay: .8s;}

API

uaLoading Props

属性名类型默认值说明
modelValueBooleanfalse是否显示loading
textString-加载提示内容
spinnerString-自定义加载图标类名
backgroundString-遮罩层背景
modeStringvertical显示模式(vertical / horizontal)
sizeNumber/String24加载图标大小
loadingStyleString-自定义样式
shadeBooleantrue是否显示加载遮罩层
shadeCloseBooleanfalse点击遮罩层关闭loading
opacityNumber/String-遮罩层透明度
fullscreenBooleantrue是否全屏loading
timeNumber0loading显示时间
zIndexNumber/String2023loading层级
事件
  • @open 打开触发
  • @close 关闭触发

💝最后

开发不易,希望各位小伙伴们多多支持下哈~~ ☕️☕️

loading: loading加载组件

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你想使用第三方的 Vue 3 表格组件封装一个表格,可以按照以下步骤进行操作: 1. 安装所需的表格组件。以 Element Plus 为例,你可以使用以下命令进行安装: ``` npm install element-plus ``` 2. 在你的 Vue 3 项目中导入并注册表格组件。在你的 main.js 文件中添加以下代码: ```javascript import { createApp } from 'vue'; import ElementPlus from 'element-plus'; import 'element-plus/dist/index.css'; import App from './App.vue'; const app = createApp(App); app.use(ElementPlus); app.mount('#app'); ``` 3. 创建一个新的 Vue 组件,用于封装表格。在这个组件中,你可以使用 Element Plus 提供的 Table 组件。 ```vue <template> <el-table :data="tableData"> <el-table-column v-for="column in tableColumns" :key="column.prop" :prop="column.prop" :label="column.label"> </el-table-column> </el-table> </template> <script> export default { data() { return { tableColumns: [ { prop: 'name', label: 'Name' }, { prop: 'age', label: 'Age' }, { prop: 'city', label: 'City' } ], tableData: [ { id: 1, name: 'John Doe', age: 25, city: 'New York' }, { id: 2, name: 'Jane Smith', age: 30, city: 'San Francisco' }, { id: 3, name: 'Bob Johnson', age: 35, city: 'Los Angeles' } ] }; } }; </script> ``` 在这个示例中,我们使用了 Element Plus 的 Table 组件,并通过 `tableColumns` 和 `tableData` 来动态渲染表格的列和数据。 你可以根据具体的表格组件的文档和需求,进一步自定义和扩展你的表格组件

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值