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