vue 图片,视频点击预览按钮方法

图片

使用el-image-viewer组件

写之前注意引入安装组件!!!

主要代码:

<div class="">
      <el-image-viewer v-if="showViewer" :on-close="()=>{showViewer=false}" :url-list="[pic]"/>
</div>

按钮方法:

    viewque(img) {  //按钮触发
      this.showViewer = true;
      this.pic = img;
    },

视频

使用vue-video和 a-modal

<a-modal
  v-model="visibleVideo"
  :footer="null"
  :zIndex="1004"
  :width="900"
  :maskClosable="false"
>
  <my-video v-if="visibleVideo" :sources="video.sources" :options="video.options"></my-video>
</a-modal>
videoque(src) {
  console.log(111)
  this.visibleVideo = true;
  this.video.sources[0].src = src;
  console.log(this.video.sources[0].src)
}
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现 Ant Design Vue Draggable 组件的图片预览方法,可以使用 Vue.js 的插件 vue-preview,它可以轻松地将图片预览功能添加到您的应用程序中。以下是实现步骤: 1. 安装 vue-preview 插件 使用 npm 安装 vue-preview 插件: ``` npm install vue-preview --save ``` 2. 在 main.js 中引入和使用插件 在 main.js 中引入 vue-preview 插件,并将其作为 Vue.js 插件使用: ```javascript import VuePreview from 'vue-preview' Vue.use(VuePreview) ``` 3. 在 Draggable 组件中添加图片预览功能 在 Draggable 组件中,添加一个图片预览按钮或者图标,当用户点击按钮时,触发图片预览功能。可以使用 vue-preview 的 `preview` 方法实现: ```html <template> <div> <draggable v-model="list"> <div v-for="item in list" :key="item.id"> <img :src="item.src" alt="item.name"> </div> </draggable> <button @click="previewImages">预览</button> </div> </template> <script> export default { data() { return { list: [ { id: 1, src: 'https://example.com/image1.jpg', name: 'Image 1' }, { id: 2, src: 'https://example.com/image2.jpg', name: 'Image 2' }, { id: 3, src: 'https://example.com/image3.jpg', name: 'Image 3' } ] } }, methods: { previewImages() { // 获取所有图片元素 const imgs = Array.from(document.querySelectorAll('img')) // 获取图片链接列表 const urls = imgs.map(img => img.src) // 调用 vue-preview 的预览方法 this.$preview(urls) } } } </script> ``` 这样,当用户点击按钮时,会弹出图片预览窗口,用户可以方便地浏览和切换图片
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值