通过v-model控制模态框的显示隐藏
示例:
<template>
<a-modal
title=""
:centered="true"
:visible.sync="visible"
:mask="false"
:footer="null"
:width="width"
@ok="handleOk"
@cancel="handleCancel"
>
<div class="modal-tips">
<div><i class="iconfont iconStyle" :class="icon" /></div>
<div class="text">{{ text }}</div>
</div>
</a-modal>
</template>
<script>
export default {
name: 'Index',
props: {
value: {
type: Boolean,
default: false
},
text: {
type: String,
default: ''
},
width: {
type: [String, Number],
default: 300
},
icon: {
type: String,
default: 'iconbiaojiwancheng'
}
},
computed: {
visible: {
get() {
return this.value
},
set(value) {
if (this.value !== value) {
this.$emit('input', value)
}
}
}
},
methods: {
handleOk() {
this.handleCancel = false
},
handleCancel() {
this.visible = false
}
}
}
</script>
<style scoped lang="less">
.modal-tips {
padding: 40px 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.iconStyle {
font-size: 46px;
color: #1ac476;
}
.text {
font-size: 13px;
font-weight: 500;
color: #1f2329;
margin-top: 10px;
}
}
</style>
使用:
<Tips v-model="showTips" :text="tips" />