Vue ElementUI 修改MessageBox 弹框样式

1.情景还原

<template>
 <el-button type="text" @click="open">点击打开 Message Box</el-button>
</template>

<script>
 export default {
   methods: {
     open() {
       this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
         this.$message({
           type: 'success',
           message: '删除成功!'
         });
       }).catch(() => {
         this.$message({
           type: 'info',
           message: '已取消删除'
         });          
       });
     }
   }
 }
</script>
  • 感觉样式太靠下边了~~想要让它往上一些

那么我们这么改

2.

 this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          customClass: 'myClass'
        })

3.附加在没有scoped的style中

<style>
  .myClass {
     350px;
  }
</style>
原文地址:https://www.cnblogs.com/sugartang/p/13328560.html