AntDesignVue中弹窗modal组件的wrapClassName属性详解

解决modal弹出时无法点击蒙版下按钮的解决方案

近些天我在前端开发过程中遇到了这样一个需求:

  • 选择站点后modal弹出
  • 仍然可以选择其他模型参数,modal动态变化

需要展示图
在ant中的该modal组件最外层默认带有一层蒙版,z-index:999,如果想要在对话框弹出时可以点击蒙版下的其他按钮,必须要对这个蒙版下手。

解决方案

其实这里的解决方案有还挺多,但是由于我第一层包了地图,所以我也就抛弃了其他的方法,使用ant design of vue 中modal提供的 wrapClassName属性

wrapClassName:了解更多

这个属性的作业是:定义对话框外层的外层的类名。大白话翻译一下就是:给modal组件中弹出层依赖的父容器起一个类名,也就是蒙版。

代码示例

页面:
   <a-modal
      @cancel="closed"
      :mask="false"
      :centered="true"
      :zIndex="999"
      :body-style="{minHeight: '600px'}"
      :width="tableWidth-480"
      :loading="realsLoading"
      :confirmLoading="true"
      :footer="null"
      :maskClosable="false"
      :wrapClassName="test"
      :visible="projectVisible"
    >
      <template slot="title">
        <a-row>
          <a-col :span="12">
            <a style="margin-right: 37px;color: #87AFE1">
              ********
            </a>
          </a-col>
        </a-row>
      </template>
      <a-table
        :columns="projectColumns"
        :data-source="project"
        :pagination="false"
        size="small"
        rowKey="id"
        :locale="{emptyText:'暂无数据'}"
        :loading="projectLoading"
        :row-selection="{selectedRowKeys:keys,onChange:projectSelection, columnTitle: '选择',type: 'radio'}">
        <template slot="user" slot-scope="text, user">
          {{ user.user | empty }}
        </template>
        <template slot="nsce" slot-scope="text, nsce">
          {{ nsce.nsce | empty }}
        </template>
        <template slot="bias" slot-scope="text, bias">
          {{ bias.bias | empty }}
        </template>
        <template slot="errp" slot-scope="text, errp">
          {{ errp.errp | empty }}
        </template>
        <template slot="errt" slot-scope="text, errt">
          {{ errt.errt | empty }}
        </template>
        <template slot="operation" slot-scope="text, operation">
          <a @click="onDelete(operation)">
            <a-icon type="delete" />
          </a>
        </template>
      </a-table>
    </a-modal>
data:
export default {
data (){
 tableWidth: window.innerWidth,
      test: 'top-200',
}
样式:
.top-200{
  top: 65px;
  right: 384px;
  border: 1px solid red;//演示加的,用的时候删掉就好
}

}

效果展示

  • 外层蒙版位置已被移动

此时外层蒙版的位置

  • 点击后也能正常展示

点击按钮后的效果

最后:其实这对很多人来说不算是可以写博客记录的问题,可能是我之前更多的精力都放在了后端,对前端不太熟悉,再次也提醒自己,注意细节,多看文档,多多学习。

总结

解决问题的方式有很多种,选择很重要,写这个博客只为了记录当下解决问题的思路,如果能帮助到你那就更好了,希望不要搬运,谢谢。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值