常见的confirm确认框写法

275 阅读1分钟

项目中比较常见的confirm确认框写法


this.$confirm('确认退出登录吗?', '提示', {
  confirmButtonText: '确认',
  cancelButtonText: '取消',
  type: 'warning'
}).then(() => {
 //确认的函数
})

VUE+elementUI写法:

onStopClick(row: any) {
    **this.$confirm**('确定停用该条消息吗 ?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
      .then(() => {
        this.requestSwitchStatus(row)
      })
      .catch(() => {})
  }

VUE+VUX 写法


            this.$vux.confirm.show({
              title: 标题,
              content: content,
              onCancel() {
                let url = window.location.href
                if (url.indexOf('isApp') > -1) {
                  _this.goNV({type: ''})
                } else {
                  _this.$router.push('/home')
                }
              },
              onConfirm() {
                _this.crushEggRequest(param)
              }
            })```