随笔 - 142  文章 - 14  评论 - 0  阅读 - 70370

日常开发记录-this.$message,this.$prompt,交换弹窗确定和取消按钮的位置,确定在左,取消在右

代码:

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

<script>
export default {
  methods: {
    open () {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        // MessageBox 的自定义类名
        customClass: 'btn-cancle-right'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>
// 在单页面使用不可以加scoped限制,否则不生效
<style lang="scss">
/* 可以把这个btn-cancle-right类放置到公共的样式文件中,
这样就可以只定义一次,多次重复使用啦 */
.btn-cancle-right {
  .el-message-box__btns {
    .el-button:nth-child(1) {
      float: right;
    }
    .el-button:nth-child(2) {
      margin-right: 10px;
      background-color: #2d8cf0;
      border-color: #2d8cf0;
    }
  }
}
</style>
复制代码

图示:

 

posted on   法老的微笑  阅读(549)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示