uniapp二次确认弹框组件(依赖于uview)
# 使用方法
- 引入
import KekeConfirm from "@/components/KekeConfirm"
1
- 应用
kekeConfirm({
show: true,
title: '提示',
message: '确认删除这个评论吗?',
}).then(async () => {
// 此处填写二次确认后执行的逻辑
})
1
2
3
4
5
6
7
2
3
4
5
6
7
- 源码(KekeConfirmModal.vue, index.js)
<template>
<u-modal
:show="content.show" width="600rpx"
v-if="isShow"
:showConfirmButton="true"
:showCancelButton="true"
confirmColor="rgba(15, 168, 172, 1)"
@confirm="confirm" @cancel="cancel"
>
<view class="slot-title">{{ content.title }}</view>
<view class="slot-content">
{{ content.message }}
</view>
</u-modal>
</template>
<script>
export default {
name: "KekeConfirmModal",
data() {
return {
isShow: true,
content: {
title: '提示',
message: '',
show: false
}
};
},
methods: {
confirm() {
// console.log('确定');
},
cancel() {
// console.log('取消');
}
},
};
</script>
<style lang="scss" scoped>
/deep/.u-modal__content {
display: block;
}
.slot-title {
font-size: 30rpx;
font-weight: bold;
color: #606266;
text-align: center;
}
.slot-content {
text-align: center;
padding-top: 20rpx;
white-space: pre-line;
font-size: 28rpx;
font-family: Font-Regular, Heiti SC;
font-weight: 400;
color: #767676;
}
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Vue from 'vue'
import KekeConfirmModal from './KekeConfirmModal.vue'
const KekeConfirm = Vue.extend(KekeConfirmModal)
const kekeConfirm = (content) => {
return new Promise((resolve, reject) => {
let confirmDom = new KekeConfirm({
el: document.createElement('div')
})
document.body.appendChild(confirmDom.$el)
// confirmDom.title = content
confirmDom.content = {
...content
}
confirmDom.confirm = () => {
resolve()
confirmDom.isShow = false
}
confirmDom.cancel = () => {
// reject()
confirmDom.isShow = false
}
})
}
export default kekeConfirm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
上次更新: 2023/07/07, 17:17:48