解决iview modal拖动出边界问题

iview modal 弹窗拖出边界就拖不回来了,并且关闭后再打开还是在原位置,必须刷新页面才可正常显示,问题图片如下

在这里插入图片描述
在这里插入图片描述

解决思路:
1、改源码,太麻烦直接pass
2、用自定义指令覆盖原实现

废话不多说,直接上源码

//vue绑定事件的工具类
import {
   off, on} from './components/libs/dom'
Vue.directive('dragControl', {
   
    bind: function (el, binding, vnode) {
   

        let componentInstance = vnode.componentInstance;
        el.dataset.initWidth = componentInstance.width.toString();
        el.dataset.visible = componentInstance.visible.toString();
        //获取modal 的底部

        let footer = componentInstance.$refs.content.getElementsByClassName("ivu-modal-footer");
        let customFooter = componentInstance.$refs.content.getElementsByClassName("panel-footer");
        if (footer.length > 0) {
   
            footer[0].style.cssText = "cursor: move";
            //modal 底部绑定mousedown事件
            on(footer[0], "mousedown", componentInstance.handleMoveStart);
        }
        if (customFooter.length > 0) {
   
            customFooter[0].style.cssText = "cursor: move";
            //modal 底部绑定mousedown事件
            on(customFooter[
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值