详解elementui之el-image-viewer(图片查看器)
网络编程 2021-07-04 15:51www.168986.cn编程入门
这篇文章主要介绍了详解elementui之el-image-viewer(图片查看器),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们狼蚁网站SEO优化随着长沙网络推广来一起学习学习吧
前言
随着版本的更新Element UI新增了新的组件,例如:,没错今天被我发了Image狼蚁网站SEO优化可通过 previewSrcList 开启预览大图的功能。
这是官方文档中有写的,但是我想不使用Image组件又想使用预览大图的功能是否可行呢?
答案是当然可以。
使用方法
翻看了Image的源码,发现大图预览是一个小组件image-viewer,打开看看它的props,如下
props: { urlList: { type: Array, default: () => [] }, zIndex: { type: Number, default: 2000 }, onSwitch: { type: Function, default: () => {} }, onClose: { type: Function, default: () => {} } }
我们需要使用到的就只有urlList与onClose两个属性 ,一个用来放图片链接一个用来关闭查看器。
需要使用的属性我们知道了,然后我们就在代码里面引入image-viewer就可以直接使用。
<template> <div> <el-button @click="onPreview">预览</el-button> <el-image-viewer v-if="showViewer" :on-close="closeViewer" :url-list="[url]" /> </div> </template> <script> // 导入组件 import ElImageViewer from 'element-ui/packages/image/src/image-viewer' export default { name: 'Index', ponents: { ElImageViewer }, data() { return { showViewer: false, // 显示查看器 url:'https://cube.elemecdn./6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg' } }, methods: { onPreview() { this.showViewer = true }, // 关闭查看器 closeViewer() { this.showViewer = false } } </script>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持狼蚁SEO。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程