vue(父子组件)使用element弹窗功能

news/2024/7/24 6:53:07 标签: vue.js, 弹窗, 父子组件传值, elements

vue(父子组件)使用element弹窗功能

注意点

  1. 注意使用父子组件传值的时候,props的值是单项的。
  2. 所以说在做弹窗的时候我们需要先,父组件向子组件传值,然后子组件向父组件传值。

父组件

<template>
  <div>
    <div class="displayVideo">
      <template>
        <ul v-infinite-scroll="load"  class="personalDiaplayLine infinite-list" style="overflow:auto">
          <li v-for=" ( item,index ) in personalDiaplayLine" :key="index">
            <ul>
              <li v-for="( ite,ind ) in personalDiaplay" :key="ind ">
                <img :src="ite.url" :title="ite.title" width="100%" height="100%" @click="videoSpring">
                <i class="videospanclose" />
                <p>{{ ite.title }}</p>
              </li>
            </ul>
          </li>
        </ul>
      </template>
    </div>
    <VideoFrame :display="display" @sendFVideo="getMsgVideoSon" />
    <!-- <el-dialog
      :visible.sync="dialogVisible"
      width="55%"
    >
      <div class="boxDisplay">
        <easy-player :video-url="videoUrl" :poster="videoImg" />
      </div>
    </el-dialog> -->
  </div>
</template>

<script>
import EasyPlayer from '@easydarwin/easyplayer'
import 'videojs-contrib-hls'
import VideoFrame from '@/components/file/video/videoFrame'
export default {
  name: 'File',
  // eslint-disable-next-line vue/no-unused-components
  components: { EasyPlayer, VideoFrame },
  data() {
    return {
      display: false,
      personalDiaplayLine: 0,
      videoUrl: require('@/assets/video/DPlayer.webm'),
      videoImg: require('@/assets/3.jpg'),
      personalDiaplay: [
        { title: '江户时代那时的撒娇', url: require('@/assets/avatar.jpg') },
        { title: '江户时代那时的撒娇', url: require('@/assets/avatar.jpg') },
        { title: '江户时代那时的撒娇', url: require('@/assets/avatar.jpg') },
        { title: '江户时代那时的撒娇', url: require('@/assets/avatar.jpg') },
        { title: '江户时代那时的撒娇', url: require('@/assets/avatar.jpg') }
      ]
    }
  },
  mounted() {
    // this.baseAddr = process.env.VUE_APP_SER_ADDR + manager
  },
  created() {
    this.sumLine()
  },
  methods: {
    videoSpring() {
      this.display = true
    },
    getMsgVideoSon(data) {
      this.display = data
    },
    sumLine() {
      if (parseInt(this.personalDiaplay.length / 3) > 3) {
        this.personalDiaplayLine = parseInt(this.personalDiaplay.length / 3)
      } else {
        this.personalDiaplayLine = 1
      }
    },
    load() {
      this.personalDiaplayLine += 2
    }
  }
}
</script>

<style lang="scss" scoped>
*{
  list-style: none;
}
  .type-icon{
    display: inline-block;
    width: 12px;
    height: 12px;
  }
.displayVideo {
  width: 100%;
  height: 70vh;
  overflow: auto;
  // overflow-x: hidden;
  // overflow-y: auto;
  .personalDiaplayLine{
  display: block;
  width: 100%;
  height:100%;
  padding: 0 !important;
  margin-left: -1%;
  li:nth-of-type(1){
    margin-top: -1%;
    padding: 0 !important;
  }
  li{
    width: 100%;
    height: 30%;
    margin-top: 2.5%;
    ul{
      width: 100%;
      height: 100%;
       li:nth-of-type(1){
          margin-top: 2.5%;
        }
      li{
        width: 30%;
        margin-left: 2%;
        height: 100%;
        float: left;
        position: relative;
        top: -7.5%;
        overflow: hidden;
        display: flex;
        justify-content: center;
        cursor: pointer;
        img{
          position: relative;
        }
        .play{
          width: 30px;
          height: 30px;
          position: absolute;
          top: 88%;
          left: 86%;
          cursor: pointer;
          z-index: 100;
        }
       p{
          margin: 0;
          width: 100%;
          height: 25px;
          line-height: 25px;
          color: #fdfbfb;
          background-color: rgb(42, 37, 37);
          text-align: left;
          overflow:hidden;
          text-overflow:ellipsis;
          white-space:nowrap;
          position: absolute;
          top: calc(100% - 25px);
          left: 0;
          font-size: 14px;
          padding-left: 3%;
        }
      }
    }
  }
  }
}
.videospanclose:after {
  font-family: 'element-icons';
  position: absolute;
  top: 1vh;
  left: 90%;
  font-size: 20px;
  content: "\E6DB";
  cursor: pointer;
}

</style>

子组件

<template>
  <div>
    display:{{display}}
    <el-dialog
      :visible.sync="display"
      width="55%"
      @close="videoDisplayClose"
    >
      <div class="boxDisplay">
        <easy-player :video-url="videoUrl" :poster="videoImg" />
      </div>
    </el-dialog>
  </div>
</template>
<script>
import EasyPlayer from '@easydarwin/easyplayer'
import 'videojs-contrib-hls'
export default {
  components: { EasyPlayer },
  // eslint-disable-next-line vue/require-prop-types
  props: {
    display: {
      type: Boolean,
      required: true
    }
  },
  data() {
    return {
      CountTo: 0,
      videoUrl: require('@/assets/video/DPlayer.webm'),
      videoImg: require('@/assets/3.jpg')
    }
  },
  methods: {
    // 关闭事件
    videoDisplayClose() {
      // eslint-disable-next-line eqeqeq
      this.$emit('sendFVideo', false)
    }
  }
}
</script>
<style lang="scss" scoped>
/deep/ .el-dialog{
color: white;
height: 60vh !important;
margin-top: 20vh !important;
position: relative;
}
.boxDisplay{
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}.test{
  width: 20px;
  height: 30px;
  background-color: antiquewhite;
  font-size: 20px;
  color: red;
}
</style>

http://www.niftyadmin.cn/n/482787.html

相关文章

iO开发 -Masonry学习,让你一看就会用,一看就能上手项目

在这里问下大家&#xff0c;用的约束方式是哪种&#xff1f;近年来&#xff0c;约束这件事情在开发中的分量越来越重&#xff0c;不同机型的问世&#xff0c;使得原来使用系数的开发人员苦不堪言&#xff0c;一开始约束的使用让很多人很不习惯&#xff0c;网上给出的Demo也层出…

Echarts-饼图

Echarts-饼图 代码 const colors [#2EC7C9, #B6A2DE, #D87A80, #FFB980, #00c6ff, #2EC7C9].reverse() var data [{name: 户外大屏,value: 10},{name: 广告条屏,value: 20},{name: 其他,value: 30},{name: 公共交通,value: 40},{name: 广播,value: 50} ] var total data.re…

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1

报错如下&#xff1a; ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 且pod中有如下警告&#xff1a; [!] The xxxxxxxxx [Debug] target overrides the OTHER_LDFLAGS build setting d…

web视频播放组件(easyplayer)和音频组件播放封装(vue-aplayer)

web视频播放组件&#xff08;easyplayer&#xff09;和音频组件播放封装&#xff08;vue-aplayer&#xff09; 使用只需要传相应的参数就可以使用&#xff0c;比较方便快捷。 easyplay使用教程&#xff1a;https://blog.csdn.net/qq_44891434/article/details/118525941 vue…

iOS开发-导航栏标题动画

正常做这种导航栏隐藏一般都是整体改变透明度实现的&#xff0c;觉得太low 了&#xff0c;所以就想能不能做的高大上一点&#xff0c;直接飞过去&#xff0c;于是乎就有了这 个动画&#xff0c;下面放上代码&#xff0c;下载链接放在文末&#xff1a; //核心的东西都在scrollV…

vue前后端分离项目各种请求封装+应用

vue前后端分离项目各种请求封装+应用 目录 http.js import axios from axios import qs from qs import httpApi from ./httpApi.js // const baseSrc = "" function setUrl(src) {let url = httpApi.api.baseSrc + httpApi.api[src]return encodeURI(url) }funct…

iOS12网页视频播放点击全屏按钮会导致闪退

最近在app中有一个h5界面&#xff0c;是一个视频播放的列表&#xff0c;然后在iOS12的手机上发生了如下几个问题&#xff1a; 第一&#xff0c;自动全屏播放&#xff0c;这个问题历来就有&#xff0c;很好解决&#xff1b; 第二&#xff0c;全屏后取消全屏&#xff0c;状态栏消…

怎么访问云服务器上的图片

怎么访问云服务器上的图片 1. 准备工作 你需要在阿里云或者腾讯云购买云服务器。配置宝塔面板。安装Tomcat 2. 具体操作步骤 1. 安装好Tomcat 2. 在宝塔界面开启相应的端口&#xff0c;端口为 8080 3. ip8080&#xff0c;访问一下&#xff0c;看是否出现如下图的界面&…