MessageBox彈框
阿新 • • 發佈:2021-02-01
技術標籤:elementUI
<!-- 匯入 -->
import { MessageBox } from 'element-ui';
Vue.prototype.$confirm = MessageBox.confirm
<script>
// 根據Id刪除對應的使用者資訊
async removeUserById(id) {
// 彈框詢問使用者是否刪除資料
const confirmResult = await this.$confirm(
'此操作將永久刪除該使用者, 是否繼續?',
'提示' ,
{
confirmButtonText: '確定',
cancelButtonText: '取消',
type: 'warning'
}
).catch(err => err)
// 如果使用者確認刪除,則返回值為字串 confirm
// 如果使用者取消了刪除,則返回值為字串 cancel
if (confirmResult !== 'confirm') {
return this.$message.info('已取消刪除')
}
const { data: res } = await this.$http.delete('users/' + id)
this.$message.success('刪除使用者成功!')
this.getUserList()
},
</script>