mint-ui裏面的MessageBox怎麼去判斷確認仍是取消

MessageBox.confirm('', {
          title: '請注意',
          message: '添加供應商前,請先搜索該供應商是否存在,請勿重複添加',
          showCancelButton: true,
          confirmButtonText: '去搜索',
          cancelButtonText: '新增'
        }).then((res) => {
          console.log(res)
          if (res === 'confirm') {
            this.$nextTick(() => {
              this.$refs.gain.focus()
            })
          }
        }).catch(() => {
          navigation('/supplier/editSuppplierInfo')
        })

這裏的catch很重要,在then裏面去判斷確認.catch裏面就是返回取消的了this

相關文章
相關標籤/搜索