vue自定义div弹窗打开失败

在写自定义div弹窗的时候,实现类似el-dlaig打开关闭的效果。

  1. showDialog的时候 div怎么也打不开,并且页面中也没有插入那块dom;

  2. dialogVisible默认是true的时候是能正常展示div的

解决办法:类似el-dlalog的appen-to-body属性

找到对应源码

CV一下

成功解决!

javascript 复制代码
<!--
 * @Description: 百度地图点聚合点位详情弹窗 页面
 * @Author: mhf
 * @Date: 2024/9/29 13:37
-->
<template>
  <div class="bd-cluster-detail-dialog" v-if="dialogVisible">
    详情
    <el-button type="primary" @click="hideDialog">buttonCont</el-button>
  </div>
</template>

<script>
export default {
  name: "bdClusterDetailDialog",
  components: {},
  props: {
  },
  data() {
    return {
      dialogVisible: false,
    };
  },
  methods: {
    showDialog(data) {
      this.$message.success("打开")
      this.dialogVisible = true
      document.body.appendChild(this.$el);
    },

    hideDialog() {
      this.dialogVisible = false;
    },
  },
  created() {
  },
  mounted() {
  },
};
</script>

<style lang="scss" scoped>
.bd-cluster-detail-dialog {
  width: 400px;
  height: 600px;
  border: 1px solid red;
  z-index: 20000 !important;
  position: absolute;
  right: 100px;
  top: 100px;
}
</style>
相关推荐
一木 之林12 分钟前
LangChain 第6章 Agent 智能体核心:create_agent 统一入口与 ReAct 循环
前端·react.js·langchain
不可能片场31 分钟前
Electron 发布进程被回收 用脱离进程组托住
前端·electron
kaixin_learn_qt_ing37 分钟前
hexdump -C /path/to/binary | less 看十六进制内容
前端·css·less
java1234_小锋38 分钟前
【技术专题】HTML5 网页技术 - HTML5 链接与图片
前端·html·html5
sun_weitao41 分钟前
Chrome 扩展插件开发指南
前端·javascript·chrome
小马不起床1 小时前
零基础玩转 FastAPI_12:前端详情增强与角色权限分配
前端·状态模式·fastapi
labview_自动化1 小时前
cvat部署记录
javascript·labview
前端snow1 小时前
ai agent --- 切割文件 RecursiveCharacterTextSplitter
前端
松就是我902981 小时前
可编辑 PPT:调研、设计与实施方案
前端
前端snow1 小时前
ai agent --- Elasticsearch 混合检索
前端