首页 > 其他分享 >vue多个el-popover使用(打开不卡顿,可正常关闭)

vue多个el-popover使用(打开不卡顿,可正常关闭)

时间:2024-07-05 10:34:38浏览次数:10  
标签:el vue String index default 不卡顿 popover type

最近写vue遇到了点问题

  同页面多个el-popover打开卡顿问题、无法关闭问题

解决方案,组件化封装el-popover

组件模板定义

<template>
    <div class="screen">
      <el-popover
        :placement="placement"
        :width="screenWidth"
        trigger="click"
        popper-class="popperScreen"
        :title="title"
        :ref="myRef"
      >
        <div>
          <slot name="myContext"></slot>
        </div>
        <div style="text-align: center; margin: 10px 0 0 0">
          <el-button class="smallBtn" @click="determine">确定</el-button>
          <el-button class="skyBtn" @click="cancel">取消</el-button>
        </div>
        <!-- <div slot="reference" class="selectStyle mt5 ml10">{{ screenTitle }}</div> -->
        <div slot="reference" class="selectStyle mt5 ml10"><slot name="myReference"></slot></div>
        
      </el-popover>
    </div>
  </template>
  <script>
  export default {
    name: "my-popover",
    data() {
      return {}
    },
    props: {
      myRef:{
        type: String,
        default: 'myRef'
      },
      // 箭头位置
      placement: {
        type: String,
        default: 'bottom-start'
      },
      // 宽度
      screenWidth: {
        type: String,
        default: '400'
      },
      // 标题
      title: {
        type: String,
        default: '请选择筛选条件'
      },
      // 按钮标题
      screenTitle: {
        type: String,
        default: '请筛选'
      }
    },
    methods: {
      determine() {
        this.$emit('submitScreenData')
      },
      cancel() {
        this.$emit('resetScreenData')
      }
    }
  }
  </script>
  <style lang="less">
  .el-popover.popperScreen {
    margin-top: 5px !important;
  }
</style>
  

页面注册组件

import MyPopover from './my-popover.vue'

页面使用

<template>
  <my-popover ref="customerInvoice" :myRef="`quantity-${scope.$index}`" :screenWidth="`300px`" @resetScreenData="resetScreenData(scope.$index)"   @submitScreenData="submitScreenData(scope.$index)">     <el-input slot="myContext" v-model="repertoryConsumeQuantity" type="text" clearable ></el-input>     <span slot="myReference" style="color:blue">{{ scope.row.consumeQuantity}}</span>   </my-popover>
</template>
<script>
methods: {
    resetScreenData(index) {
      console.log(index)
      this.$refs.customerInvoice.$refs[`quantity-${index}`].doClose()
    },
    submitScreenData(index) {
      console.log(index)
      this.$refs.customerInvoice.$refs[`quantity-${index}`].doClose()
    },
}
</script>

标签:el,vue,String,index,default,不卡顿,popover,type
From: https://www.cnblogs.com/ywzq/p/18285227

相关文章

  • 使用EasyExcel的AnalysisEventListener读取EXCEL导入数据
    1、实体对象VOimportcom.alibaba.excel.annotation.ExcelProperty;importlombok.Data;@DatapublicclassPrizeLogImportExcelVO{@ExcelProperty("订单编号")privateStringprizeSn;@ExcelProperty("快递公司")privateStringexpressN......
  • BeanUtil复制时,两对象中数据类型不一致导致的问题Can not set java.time.LocalDateTim
    @DatapublicclassAVo{privateLongendTime;privateStringname;privateStringid;}@DatapublicclassABVo{privateLocalDateTimeendTime;privateStringname;privateStringid;}AVoaVo=newAVo();......
  • 艾宾浩斯遗忘曲线复习计划表Excel下载
    艾宾浩斯遗忘曲线复习计划表Excel下载 改造自贵乎大神的Excel:艾宾浩斯遗忘曲线怎么用?链接:https://pan.baidu.com/s/1rqQLOPXAxTxDs_Tk9fIN5A提取码:u53x如果失效了,记得提醒我 日期:是从今天2020/11/02计划到2025/05/26用法:不要修改或删除任何日期(任何一行都不要删除掉......
  • 【YOLOv10改进 - 注意力机制】 MHSA:多头自注意力(Multi-Head Self-Attention)
    YOLOv10目标检测创新改进与实战案例专栏专栏链接:YOLOv10创新改进有效涨点介绍摘要我们介绍了BoTNet,这是一个概念简单但功能强大的骨干架构,将自注意力引入多个计算机视觉任务,包括图像分类、物体检测和实例分割。通过仅在ResNet的最后三个瓶颈块中用全局自注意力替换......
  • vue2和vue3自定义指令实现只读模式,禁止用户编辑
    解决代码表单组件大量disable的麻烦,实现只读。只需要在需要的地方加上v-read-only即可达到只读效果,快捷方便。实现思路父元素下添加一个遮罩层元素遮罩层元素的显示隐藏由参数决定要想简单快捷的实现,最好用的就是写一个遮罩层,通过遮罩来隔绝用户的操作。原始代码如下:<temp......
  • RabbitMq shovel 将一个实例的消息转发到另一个实例的队列
    RabbitMqshovel将一个实例的消息转发到另一个实例的队列一、shovel是什么?其实,shovel和上一篇博客中的federation的功能是类似的,都是为了MQ间的消息同步。不同的是,federation需要每个MQ上都配置,它只是个拉取消息的功能,而shovel只需要在一个MQ上配置即可,它是个双向的动作,既能拉......
  • 基于Java+SpringBoot+Vue的学生宿舍管理系统的设计与开发(源码+lw+部署文档+讲解等)
    文章目录前言项目背景介绍技术栈后端框架SpringBoot前端框架Vue数据库MySQL(MyStructuredQueryLanguage)具体实现截图详细视频演示系统测试系统测试目的系统功能测试系统测试结论代码参考数据库参考源码获取前言......
  • 【权威出刊|投稿优惠】2024年城市工程与低碳发展国际会议(ICUELCD 2024)
    2024年城市工程与低碳发展国际会议2024InternationalConferenceonUrbanEngineeringandLowCarbonDevelopment【1】大会信息会议简称:ICUELCD2024大会时间:点击查看大会地点:中国·成都截稿时间:点击查看审稿通知:投稿后2-3日内通知会议官网:http://www.icuelcd.co......
  • vue学习笔记6
    1.组件事件Parent.Vue中的代码<template><h3>Parent</h3><br/><Child@someEvent="getChildDataHandler"/><p>{{message}}</p></template><script>//1.引入组件impo......
  • powershell遍历文件夹压缩以及编写生成k3配置
    Add-Type-AssemblyNameSystem.IO.CompressionAdd-Type-AssemblyNameSystem.IO.Compression.FileSystem#设置源文件夹和目标日志文件的路径$sourceFolder="C:\myapp\bin"$destFolder="C:\myapp\OutPut\"$logFilePath="C:\myapp\log.x......