组件封装|小程序封装弹窗组件
小程序常用弹窗组件封装:
子组件
html部分
// 定义弹窗内容
样式部分:
.mask {
z-index: 100;
position: fixed;
width: 100%;
height: 100%;
left: 0;
top: 0;
background-color: rgba(0, 0, 0, .75);
text-align: center;
}.pop-container {
box-sizing: border-box;
position: fixed;
top: 50%;
width: 100%;
transform: translateY(-50%);
padding-left: 95rpx;
padding-right: 95rpx;
text-align: center;
}.mask-close {
display: inline-block;
margin-top: 50rpx;
width: 80rpx;
height: 80rpx;
background: url(../../images/close.png) no-repeat;
background-size: 100%;
}
// 自定义弹窗
.pop-content1 {
position: relative;
box-sizing: border-box;
width: 601rpx;
height: 734rpx;
margin-top: -50rpx;
border-radius: 20rpx;
backgrount: white;
text-align: center;
padding-right: 33rpx;
padding-top: 462rpx;
}
js部分
> export default {
data() {
return {
isShow: false
};
},
props: ['run'],
name: 'entrancePop',
config: {
component: true
},
methods: {
show(value) {
this.isShow = true;
this.$emit('run', true);
}
},
hide() {
this.isShow = false;
this.$emit('run', false);
}
}
};
父组件调用
// 在最外层view上添加:style="viewStyle"
>
import EntrancePop from '../../components/Pop/EntrancePop';
export default {
components: {
'entrance-pop': EntrancePop
},
methods: {
noRoll(slide) {
if (slide === true) {
this.viewStyle = {
position: 'fixed'
};
} else if (slide === false) {
this.viewStyle = {};
}}
}}
【组件封装|小程序封装弹窗组件】弹窗组件的步骤大概就是这样啦希望可以帮助要需要的同学
推荐阅读
- 一个小故事,我的思考。
- 家乡的那条小河
- 一个人的碎碎念
- 野营记-第五章|野营记-第五章 讨伐梦魇兽
- 昨夜小楼听风
- 2021-02-17|2021-02-17 小儿按摩膻中穴-舒缓咳嗽
- 基于微信小程序带后端ssm接口小区物业管理平台设计
- 2019.4.18感恩日记
- 那件我们忽略的小事叫感恩
- 2020-04-07vue中Axios的封装和API接口的管理