如图所示:
等待数据返回等等...
开箱即用比UI好用
<template>
<div>
<button @click="showLoading">显示加载中消息</button>
<div v-if="loading" class="loading">
<div class="loading-message">
<div class="loading-spinner"></div>
<div class="loading-text">加载中...</div>
</div>
</div>
</div>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const loading = ref(false)
function showLoading() {
loading.value = true
}
function hideLoading() {
loading.value = false
}
return {
loading,
showLoading,
hideLoading
}
}
}
</script>
<style>
.loading {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
.loading-message {
position: relative;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 10px;
padding: 20px;
}
.loading-spinner {
width: 30px;
height: 30px;
border-radius: 50%;
border: 2px solid #fff;
border-top-color: transparent;
animation: spin 0.8s linear infinite;
margin-right: 10px;
}
.loading-text {
color: #fff;
font-size: 16px;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
</style>
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容