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 {
    width: 350px;
  }
</style>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM