项目点滴
vue前端零碎用例
前言
随便写写的,仅供参考,不喜勿喷
一、 1. vue中的this.$confirm()用法
普通的确认取消弹窗,因为Vue 内置 API 里并没有 $confirm,所以引用了element ui。
二、使用步骤
代码如下(示例):
var that = this
this.$confirm({
title: "标题",
content: e == '1' ? '内容1' : '内容2',//使用了三目
onOk: function () { //确定事件
that.loading = true //确认加载
postAction(that.url.release, { id: id}) //传参后台
.then((res) => {
if (res.success) { //返回成功
that.$message.success(res.message)
that.loadData() //加载
that.clearList()
} else {
that.$message.error(res.message) //返回失败
}
})
.finally(() => {
that.loading = false
})
},
})
此代码为项目代码,copy没啥用。