• 小程序-自定义模态框弹框


    小程序有官方的 wx.showModal()方法来定义弹窗内容,但是弹窗显示只能定义文本。可参考官方文档。

    自定义图片弹窗:

        <!--弹窗的页面-->
        <div class="modalMask" v-if="isModel"></div>
        <div class="modalDialog" v-if="changeModel">
          <div class="modalContent">
            <p class="contentTip">
              <image class="guide_img" src="/static/images/guide.jpg"></image>
            </p>
          </div>
          <div class="modalFooter">
            <div class="btnConfirm" @tap="confirmSend">确定</div>
          </div>
        </div>
    <span
          class="flex-sub icon-info padding-left-sm blue text-xl position-rel"
          :style="{ top:isIphone?'-14rpx':'-4rpx'}"
          @click="gotoGuide"
    ></span>

    data(){
    return{ changeModel: false, isModel: false, } }
    methods:{
        gotoGuide() {
          this.changeModel = !this.changeModel;
          this.isModel = !this.isModel;
        },
        //  确认
        confirmSend() {
          console.log("确认");
          this.changeModel = !this.changeModel;
          this.isModel = !this.isModel;
        }
        
    }

    css

    /* 引导页弹窗样式 */
    .modalMask {
       width: 100%;
       height: 100%;
       position: fixed;
       top: 0;
       left: 0;
       background: #000;
       opacity: 0.5;
       overflow: hidden;
       z-index: 9000;
       color: #fff;
     }
     .modalDialog {
       box-sizing: border-box;
       width: 640rpx;
       overflow: hidden;
       position: fixed;
       top: 50%;
       left: 50%;
       z-index: 9999;
       background: #fff;
       margin: -460rpx -320rpx;
       border-radius: 8rpx;
     }
     .modalContent {
       box-sizing: border-box;
       display: flex;
       padding: 50rpx 53rpx;
       font-size: 32rpx;
       align-items: center;
       justify-content: center;
       flex-direction: column;
     }
     .contentTip {
       text-align: center;
       font-size: 36rpx;
       color: #333333;
     }
     .teleStyle {
       background: #ffffff;
       border: 1px solid #979797;
       border-radius: 6rpx;
       line-height: 50rpx;
       height: 50rpx;
       box-sizing: border-box;
       padding-left: 12rpx;
       width: 460rpx;
       font-size: 28rpx;
       /*color: rgba(0,0,0,0.25);*/
       margin-top: 30px;
     }
     .modalFooter {
       box-sizing: border-box;
       display: flex;
       flex-direction: row;
       height: 100rpx;
       border-top: 1px solid #e5e5e5;
       font-size: 32rpx;
       line-height: 100rpx;
     }
    
     .btnConfirm {
       font-size: 32rpx;
       width: 100%;
       color: #508cee;
       text-align: center;
     }
    .guide_img{
      margin: 0 auto;
      width: 640rpx;
      height: 768rpx;
    }

    参考文章地址:https://blog.csdn.net/weixin_37787674/article/details/89674609

  • 相关阅读:
    Linux下升级gcc版本(9.1.0版本)
    Linux/CentOS系统同步网络时间的2种方法详解
    为什么使用promise
    总结js深拷贝和浅拷贝
    js闭包理解
    select框实现多选的功能
    动态添加element-ui组件
    总结鼠标移入移出事件
    echarts提示框太长,导致显示不全 ,撑大div框的问题
    vue项目中管理定时器
  • 原文地址:https://www.cnblogs.com/lpp-11-15/p/12857216.html
Copyright © 2020-2023  润新知