uni-popup实现自动弹窗

由于需要实现一个自动弹出公告的功能,开始想到了uni.showModel,但是由于uni.showModel的content样式无法更改,所以只能用uni-popup来实现。

想要的效果:

第一步,先实现页面显示

<!-- 打开弹窗 -->
		 <uni-popup ref="tipPopup" type="center" :is-mask-click="true">
		 			<view class="pop"> 
		 				<view class="title">
		 				  耀宁员工照片自助采集须知
		 				</view>
		 				<view class="content_list">
		 					<scroll-view scroll-y="true" class="scroll_view_style">
		 						<view class="tip-info">
		 							<text>{{content}}</text>
		 						</view>
		 					</scroll-view>
		 				 </view>
		         <view class="sure" @click="sure">
		           确定
		         </view>
		       </view>
		     </uni-popup>
		 

第二步,css样式问题,并将里面的内容添加滚动栏

	// 弹窗样式
.pop {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    background-color: #fff;
    border-radius: 10rpx;
	margin-top: 20rpx;
    z-index: 99;
    width: 640rpx;
    padding:10rpx 0;
  }
  .title {
    text-align: center;
    font-size: 36rpx;
    font-weight: 500;
    margin-top: 25rpx;
  }
  .tip-info {
    padding: 0 30rpx;
    font-size: 30rpx;
    color: #8f8f8f;
    margin-top: 32rpx;
    margin-bottom: 30rpx;
    text-align: left;
	line-height:28px;
	overflow-x: hidden;
	.scroll_view_style{
		height: 100%;
	}
  }
  .sure {
    width: 100%;
    border-top: 1rpx solid #ebebf0;
    height: 90rpx;
    text-align: center;
    line-height: 110rpx;
    color: rgb(0,122,255);
    font-size: 34rpx;
    font-weight: 500;
  }
.content_list {
    height: 760rpx;
	// margin-top: 10rpx;
	margin-left: 10rpx;
    overflow-x: hidden;
    .scroll_view_style{
		height: 100%;
	}
}

第三步,js

mounted:function(){
			this.open();//打开页面自动弹出
		},	
				
		methods:{
			open() {
			        this.$refs.tipPopup.open()
			      },
			      sure() {
			        this.$refs.tipPopup.close()
			      },
			}

       最后,频繁记录只为日后增长记忆,也希望可以帮助到你们!

  • 12
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值