一、el-table中加载方法
表格中加载比较简单,直接加个loading参数就行
<template>
<el-table v-loading="loading" :data="tableData" style="width: 100%">
<el-table-column prop="date" label="Date" width="180" />
<el-table-column prop="name" label="Date" width="180" />
</el-table>
</template>
<script setup>
import { ref } from 'vue'
const loading = ref(true)
const tableData = [
{
date: '2016-05-02',
name: 'John Smith'
}
]
</script>
<style>
body {
margin: 0;
}
.example-showcase .el-loading-mask {
z-index: 9;
}
</style>
第二种方法:全局加载和js调用加载
<template>
<el-button
v-loading.fullscreen.lock="fullscreenLoading"
type="primary"
@click="openFullScreen1"
>
As a directive
</el-button>
<el-button type="primary" @click="openFullScreen2"> As a service </el-button>
</template>
<script setup>
import { ref } from 'vue'
import { ElLoading } from 'element-plus'
const fullscreenLoading = ref(false)
const openFullScreen1 = () => {
fullscreenLoading.value = true
setTimeout(() => {
fullscreenLoading.value = false
}, 2000)
}
const openFullScreen2 = () => {
const loading = ElLoading.service({
lock: true,
text: 'Loading',
background: 'rgba(0, 0, 0, 0.7)',
})
setTimeout(() => {
loading.close()
}, 2000)
}
</script>
上一篇:
没有了
下一篇:
js中slice和splice的用法