<template>
<view>
<view class="modal-view" :class="[`modal-view-${position}`, hidden ? 'show' : '']">
<view class="modal-container">
<view class="modal-header">
<slot name="header"></slot>
<view class="cancel" @tap.stop="cancel"></view>
</view>
<scroll-view class="scroll" scroll-y="true">
<slot></slot>
</scroll-view>
<view class="modal-footer">
<slot name="footer"></slot>
</view>
</view>
</view>
</view>
</template>
<script>
import { ref, defineComponent,defineExpose } from 'vue';
export default defineComponent({
name: 'popup',
props: {
position: {
type: String,
default: 'bottom'
},
},
setup() {
const hidden = ref(false);
const cancel = () => {
hidden.value = false;
}
const show = () => {
hidden.value = true;
}
return {
hidden,
cancel,
show
};
}
})
</script>
<style lang="scss">
.modal-view {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 999;
background: rgba(0, 0, 0, .5);
display: flex;
transition: all .2s linear;
visibility: hidden;
opacity: 0;
.modal-container {
background: #fff;
transition: transform .2s linear;
position: relative;
overflow: hidden;
border-radius: 16rpx 16rpx 0 0;
.modal-header {
height: 112rpx;
text-align: center;
position: relative;
line-height: 112rpx;
font-weight: 500;
color: #333333;
font-size: 36rpx;
.cancel {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAYZJREFUWEfVl0tugzAURX2RsoVKXVY7SVfAZwmdNEonXQKfFTSTZFmVuoVK3IrIIHBs82yIaJmC3z2+9vsAtfGDjfXV3wIoy/IBwDFJki+SH1mW/azhUF3XOwCvbds+kjwURfHdx504UFVVCSDvXgK4kNwvhdDiJ5JPXVySVZ7nhRWgaZo3ksfh5UKITpzkCcBVXG/skKbpuxXApF3ihEP8xtWbSyhd6LsbITGsWRASwAQJXetMw9BAHUjMGm8dCAkY8u3YtdlCZAtM8gJgSNFY8esllxQaH4TObTPVxDVEBOA6X6XUWW/gObZ2iAE8EIOJMdUzCKCHUEp9KqWGXS8pWP8LoLuMtt3Hnr84CzzWn0nCaDbiDBAD2NJQZ8DL3dPQJ97PCncrRBLx/vxjIbzNCMAwyWirJyXY1gnNNXO1wdmOQ8XHToRAWAeSWPEYiAmAbSQzO5+kefVpK3FiAmAOpbHiM064h9LxWL5U3AXhHcs3/zGRnu+a3wV3wzXFxb1gbdFxvF86JvgwJeevNgAAAABJRU5ErkJggg==);
width: 32rpx;
height: 32rpx;
background-size: 100% 100%;
background-repeat: no-repeat;
position: absolute;
right: 32rpx;
top: 50%;
transform: translateY(-50%);
}
}
.scroll {
height: calc(100% - 112rpx - 96rpx);
}
.modal-footer {
position: absolute;
bottom: 0;
height: 96rpx;
width: 100%;
background: #fff;
padding: 8rpx 24rpx;
box-sizing: border-box;
}
}
}
.modal-view-bottom {
align-items: flex-end;
.modal-container {
width: 100%;
height: 50vh;
}
}
.modal-view.show {
opacity: 1;
visibility: visible;
.modal-container {
transform: translate3d(0, 0, 0);
}
}
</style>
1***@163.com (作者)
<view class="add-man" @click="addRole">
<img src="../../static/addMan.png" mode="aspectFit" alt="">
<view> 添加员工</view>
</view>
代码没全部复制,不好意思
export default defineComponent({
name: 'popup',
props: {
position: {
type: String,
default: 'bottom'
},
},
setup() {
const hidden = ref(false);
const cancel = () => {
hidden.value = false;
}
const show = () => {
hidden.value = true;
}
return {
hidden,
cancel,
show
};
}
})
2022-06-17 16:06