全局loading
使用v-loading指令方式,因为Dialog的最外层元素是全屏,故遮罩为全屏。
<template>
<div>
<el-button type="text" @click="dialogVisible = true; loading = true">Open Dialog</el-button>
<el-dialog
title="提示"
:visible.sync="dialogVisible"
width="30%"
v-loading="loading"
>
<span>this is a demo</span>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
return {
loading: false,
dialogVisible: false
};
}
};
</script>
局部loading
使用服务方式时,传入dialog DOM 节点,遮罩在dialog处。文章来源:https://www.toymoban.com/news/detail-634700.html
<template>
<div>
<el-button type="text" @click="open">Open Dialog</el-button>
<el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
<span>this is a demo</span>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
return {
dialogVisible: false
};
},
methods: {
open() {
this.dialogVisible = true;
this.$loading({
target: '.el-dialog'
});
}
}
};
</script>
文章来源地址https://www.toymoban.com/news/detail-634700.html
到了这里,关于el-loading在el-dialog上使用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!