viewer 图片点击放大 用法汇总
A 不用viewer插件
1弹出框
https://www.cnblogs.com/web1/p/8989967.html
2表格中
https://www.jianshu.com/p/c17f4f62704c
3自己封装vue组件
https://www.cnblogs.com/yesyes/p/6689082.html
一、用viewer插件
效果:
1、引入文件
JS 版本:
<link rel="stylesheet" href="css/viewer.min.css">
<script src="js/viewer.min.js"></script>
jQuery 版本:
<link rel="stylesheet" href="css/viewer.min.css">
<script src="js/jquery.min.js"></script>
<script src="js/viewer.min.js"></script>
注意:JS 版本和 jQuery 版本名字虽然一样,但代码不一样,不能通用,请到 github 上下载需要的版本。
2、HTML
<ul id="dowebok">
<li><img src="img/tibet-1.jpg" alt="图片1"></li>
<li><img src="img/tibet-2.jpg" alt="图片2"></li>
<li><img src="img/tibet-3.jpg" alt="图片3"></li>
</ul>
3、JavaScript
JS 版本:
var viewer = new Viewer(document.getElementById('dowebok'));
jQuery 版本:
$('#dowebok').viewer();
配置
名称 | 类型 | 默认值 | 说明 |
---|---|---|---|
inline | 布尔值 | false | 启用 inline 模式 |
button | 布尔值 | true | 显示右上角关闭按钮(jQuery 版本无效) |
navbar | 布尔值/整型 | true | 显示缩略图导航 |
title | 布尔值/整型 | true | 显示当前图片的标题(现实 alt 属性及图片尺寸) |
toolbar | 布尔值/整型 | true | 显示工具栏 |
tooltip | 布尔值 | true | 显示缩放百分比 |
movable | 布尔值 | true | 图片是否可移动 |
zoomable | 布尔值 | true | 图片是否可缩放 |
rotatable | 布尔值 | true | 图片是否可旋转 |
scalable | 布尔值 | true | 图片是否可翻转 |
transition | 布尔值 | true | 使用 CSS3 过度 |
fullscreen | 布尔值 | true | 播放时是否全屏 |
keyboard | 布尔值 | true | 是否支持键盘 |
interval | 整型 | 5000 | 播放间隔,单位为毫秒 |
zoomRatio | 浮点型 | 0.1 | 鼠标滚动时的缩放比例 |
minZoomRatio | 浮点型 | 0.01 | 最小缩放比例 |
maxZoomRatio | 数字 | 100 | 最大缩放比例 |
zIndex | 数字 | 2015 | 设置图片查看器 modal 模式时的 z-index |
zIndexInline | 数字 | 0 | 设置图片查看器 inline 模式时的 z-index |
url | 字符串/函数 | src | 设置大图片的 url |
build | 函数 | null | 回调函数,具体查看演示 |
built | 函数 | null | 回调函数,具体查看演示 |
show | 函数 | null | 回调函数,具体查看演示 |
shown | 函数 | null | 回调函数,具体查看演示 |
hide | 函数 | null | 回调函数,具体查看演示 |
hidden | 函数 | null | 回调函数,具体查看演示 |
view | 函数 | null | 回调函数,具体查看演示 |
viewed | 函数 | null | 回调函数,具体查看演示 |
GitHub 地址:
文档: https://github.com/fengyuanchen/viewerjs/blob/master/README.md#options
二:在vscode中用法
链接:https://www.jianshu.com/p/c7e7c1550f42
第一步安装:
npm install v-viewer --save
第二步注册调用:
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
第三步注册:
Vue.use(Viewer);
Viewer.setDefaults({
Options: { "inline": true, "button": true, "navbar": true, "title": true, "toolbar": true, "tooltip": true, "movable": true, "zoomable": true, "rotatable": true, "scalable": true, "transition": true, "fullscreen": true, "keyboard": true, "url": "data-source" }
});
第四部使用:
<viewer :images="tupians">
<i-col span="4" v-for="item in tupians">
<div class="detailed">
<img :src="item.img" alt="">
</div>
</i-col>
</viewer>
数据部分
tupians:[
{
img:tupian1,
},{
img:tupian2,
},{
img:tupian3,
}
],
其他使用方法可以在github上查看viewerjs
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="js/viewer.css"/>
<script src="js/viewer.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
.img-list{
clear: both;
}
.img-list li{
width:200px;
height: 200px;
margin: 10px;
float: left;
}
img{
width: 100px;
height: 100px;
display: block;
}
</style>
</head>
<body>
<ul id="images1" class="img-list">
<li>
<img src="img/QQ图片20170920110853.png"/>
</li>
<li>
<img src="img/QQ图片20170920110853.png"/>
</li>
<li>
<img src="img/QQ图片20170920110853.png"/>
</li>
<li>
<img src="img/QQ图片20170920110853.png"/>
</li>
</ul>
<!--二-->
<ul id="image2" class="img-list">
<li>
<img src="img/QQ图片20170920110853.png" data-imgurl="img/QQ图片20170920110853.png"/>
</li>
<li>
<img src="img/QQ图片20170920110853.png" data-imgurl="img/QQ图片20170920110853.png"/>
</li>
<li>
<img src="img/QQ图片20170920110853.png" data-imgurl="img/QQ图片20170920110853.png"/>
</li>
<li>
<img src="img/QQ图片20170920110853.png" data-imgurl="img/QQ图片20170920110853.png"/>
</li>
</ul>
</body>
<script type="text/javascript">
window.onload = function(){
var viewer = new Viewer(document.getElementById('images1'), {});
//
var viewer = new Viewer(document.getElementById('image2'), {
url: 'data-imgurl'
});
}
</script>
</html>
在非Vscode项目的用法跟普通js用法一样。
this.$nextTick(function () {
viewer = new Viewer(document.getElementById('dowebok'));
})
this.$nextTick(function () {
//viewer = new Viewer(document.getElementById('dowebok'), {
// viewed: function () {
// $("body").append($(".viewer-container"))
// }
//});
})
<div id="dowebok_qm"> <Carousel v-bind:radius-dot="carouselDot_qm" dots="outside" v-bind:height="imgHeight2+'px'" v-model="carouselValue_qm" style="text-align:center;">
<div v-for="item in imgData_qm">
<Carousel-Item>
<img v-bind:src="item.src" style="height:inherit;width:auto;cursor:pointer;" />
<div><span class="carousel-text"> {{item.textName}}</span></div>
</Carousel-Item>
</div>
</Carousel>
</div>
图片名称显示的样式
.carousel-text {
position: relative;
bottom: 25px;
width: 100%;
font-size: 13px;
/*width: auto;*/ /*也可以*/
text-align: center;
color: white;
background-color: rgba(0,0,0,0.3);
}
vue的 methods中写方法
getImageListByPlantID: function (id) {
//根据id发送 ajax请求 从数据库获取该id对应的图片数据列表
this.imgData_qm=[];
let srcPart = '/ProjectFrist/Api/image/'
for (i = 0, len = imageList.length; i < len; i++) {
// 拼接对象
that.imgData_qm.push({ src: srcPart + imageList[i].ImageID + part, name: imageList[i].FileName, textName: imageList[i].textName });
}
if (that.imgData_qm.length > 10) {
that.carouselDot_qm = true; //如果图片数量大于10个则将轮播图的 横杠 换成 点。
}
vm.$nextTick(function () {
console.log("dowebok_qm 被点中");
viewer = new Viewer(document.getElementById('dowebok_qm'));
});
}
效果如下
点击图片,viewer在弹出一张大图。
viewer 图片点击放大 用法汇总的更多相关文章
- viewer && ImageFlow 图片滚动组件 图片点击放大 可以滚轮放大缩小 viewer
ImageFlow https://finnrudolph.com/products/imageflow https://github.com/countzero/ImageFlow http://w ...
- ios开发图片点击放大
图片点击放大,再次点击返回原视图.完美封装,一个类一句代码即可调用.IOS完美实现 创建了一个专门用于放大图片的类,以下为.h文件 #import <Foundation/Foundation. ...
- vue图片点击放大功能
因项目需求(ui框架element-ui),需要实现图片的点击放大,还要能旋转以及上下切换.当时第一反应,element-ui好像没有这样的组件,就想过自己写,但是那个旋转翻页上下切换感觉有点麻烦,不 ...
- Android中Textview显示Html,图文混排,支持图片点击放大
本文首发于网易云社区 对于呈现Html文本来说,Android提供的Webview控件可以得到很好的效果,但使用Webview控件的弊端是效率相对比较低,对于呈现简单的html文本的话,杀鸡不必使用牛 ...
- 动画--android图片点击放大动画,并遮挡旁边的控件
http://blog.csdn.net/s13488941815/article/details/40649823: 首先是点击放大可以使用android自带的缩放动画,因为要遮盖其他控件,就需要控 ...
- Hexo next博客的pjax一个Bug引发的关于pjax用法的小技巧-----pjax后图片点击放大的js失效
文章目录 广告: 背景 发现 解决 get技能 广告: 本人博客地址:https://mmmmmm.me 源码:https://github.com/dataiyangu/dataiyangu.git ...
- [置顶] ios 网页中图片点击放大效果demo
demo功能:点击网页中的图片,图片放大效果的demo.iphone6.1 测试通过. demo说明:通过webview的委托事件shouldStartLoadWithRequest来实现. demo ...
- vue图片点击放大预览
第一种:viewerjs使用介绍(PC.移动端都兼容) 1.先安装依赖 npm install v-viewer --save 2.main.js内引用并注册调用 //main.js import V ...
- vue实现图片点击放大
用的vue-cli开发的项目,下面是具体实现代码 子组件: <template> <!-- 过渡动画 --> <transition name="fade&qu ...
随机推荐
- oracle远程连接服务器
一.需要下载的工具 1.PLSQL Developer 下载及安装地址如下: http://www.zdfans.com/html/18196.html 2.下载instantclient-basic ...
- Reshaper \ VSCode快捷键
Reshaper 常用快捷键 Alt + F7:查找引用 Ctrl + N:Go To Everything 定位到任何,非常强大 Ctrl + Shift + N:Go To File 定位到文件 ...
- Pytorch 类别平衡化处理
采用 WeightedRandomSampler: def make_weights_for_balanced_classes(images, nclasses): count = [0] * nc ...
- Spring MVC -- JSP标准标签库(JSTL)
JSP标准标签库(JavaServer Pages Standard Tag Library,JSTL)是一个JSP标签集合,它封装了JSP应用的通用核心功能.JSTL支持通用的.结构化的任务,比如迭 ...
- SQL Server导入Excel文件报错
目录 文本被截断,或者一个或多个字符在目标代码页中没有匹配项 原因 解决方法 该值违反了该列的完整性约束 空行 没有设置为允许为NULL 我以前也导入过数据,也没报错,今天再次导入数据的时候,发现了两 ...
- TortoiseGit 查看单个文件日志显示全部提交记录了 解决办法
右击文件,Show log.后来在界面上发现,“显示整个工程”的选项.才发现不能勾这个. 去掉勾选,就可以看到单个文件日志了,如果勾选"All Branches"就可以看到该文件在 ...
- 又一神器框架:linq.js
1.支持jQuery插件的方式.jquery.linq.min.js. 2.也可以像普通js方法一样使用.linq.min.js. 3.当然用习惯VS的童鞋肯定希望有个良好的智能感知,是的,它支持. ...
- exports module.exports export export default之间的关系
exports 和module.exports是CommonJS模块规范 export export default是ES6模块的规范,两者完全是不同的概念. node应用由模块组成,采用的是Comm ...
- [LeetCode] 170. Two Sum III - Data structure design 两数之和之三 - 数据结构设计
Design and implement a TwoSum class. It should support the following operations:add and find. add - ...
- GoLand 2019.1 激活破解
链接://https://blog.csdn.net/hi_liuxiansheng/article/details/89078405