vue-preview vue图片预览插件+缩略图样式
一、安装
npm i vue-preview -S
二、main.js中 导入组件
//vue-preview 开始
import VuePreview from 'vue-preview'; // defalut install
Vue.use(VuePreview) //vue-preview 结束
三、代码
1、要为缩略图设定样式 ,要在全局样式中设定,如下:
/*图片预览 缩略图*/
.preview figure {
float: left;
width: 30%;
height:calc(30vw - 0px);
margin: 1.5%;
} .preview figure img {
width: 100%;
}
2、组件代码:
<template>
<div> <!--预览-->
<vue-preview :slides="setPreview()" class="preview"></vue-preview> </div>
</template> <script> export default {
created () {
let pid = this.$route.params.id;
//发送请求
this.$axios.get('https://www.apiopen.top/satinGodApi?type=3&page=' + pid)
.then(res=>{
this.details = res.data.data;
})
.catch(console.log)
},
data () {
return {
details:[],
}
},
methods:{
setPreview:function () {
//给预览图设置参数
this.details.forEach( img => {
img.src = img.header;
img.msrc = img.header;
img.alt = img.top_commentsName;
img.title = img.top_commentsName;
img.w = 200;//这是大图的宽
img.h = 200;
} )
return this.details;
}
}
} </script> <style scoped>
/*这里的样式无法控制缩略图*/
</style>
四、效果
1、缩略图

2、预览图

vue-preview vue图片预览插件+缩略图样式的更多相关文章
- Vue PC端图片预览插件
*手上的项目刚刚搞完了,记录一下项目中遇到的问题,留做笔记: 需求: 在项目中,需要展示用户上传的一些图片,我从后台接口拿到图片url后放在页面上展示,因为被图片我设置了宽度限制(150px),所以图 ...
- js图片预览插件,不涉及上传
小小的几十行代码,很牛逼,很实用. 支持多个图片的预览,只要new多个对象就行了. html如下 <!-- zhouxiang www.zhou-xiang.com --> <!DO ...
- eclipse 图片预览插件
eclipse 图片预览插件 CreateTime--2018年4月22日22:59:55 Author:Marydon 下载地址:eclipse 图片预览插件 将插件文件夹直接拷贝到eclips ...
- 在 vue 中使用 vieiwer 图片预览插件
https://blog.csdn.net/WestLonly/article/details/79801800?utm_source=blogxgwz0 首先,感谢原作者 官网链接 github地址 ...
- 实现一个vue的图片预览插件
vue-image-swipe 基于photoswipe实现的vue图片预览组件 安装 1 第一步 npm install vue-image-swipe -D 2 第二步 vue 入口文件引入 im ...
- vue项目中图片预览旋转功能
最近项目中需要在图片预览时,可以旋转图片预览,在网上找了下,发现有一款功能强大的图片组件:viewerjs. git-hup: https://github.com/fengyuanchen/view ...
- Vue.js图片预览插件
vue-picture-preview-extend vue-picture-preview的扩展版本,本文中插件是由其他大神开发,我做了一些扩展,原文链接:https://segmentfault. ...
- vue 图片预览插件
https://github.com/daidaitu1314/vue2-preview //cnpm cnpm install vue2-preview -save //引入 import VueP ...
- 适用于移动端、PC 端 Vue.js 图片预览插件
1.安装:npm install --save vue-picture-preview 2.使用: (1)入口文件中main.js中全局引入: import Vue from 'vue' import ...
随机推荐
- Git 如何优雅地回退代码
前言 从接触编程就开始使用 Git 进行代码管理,先是自己玩 Github,又在工作中使用 Gitlab,虽然使用时间挺长,可是也只进行一些常用操作,如推拉代码.提交.合并等,更复杂的操作没有使用过, ...
- mac office软件的安装与破解
1.mac office 软件的安装及破解 http://10176523.cn/archives/29/ 下载后安装 切记不要登录 然后用这个文件 破解
- 【新】Docker实战总结
>>> 目录 <<< Docker简介 Docker优势 Docker基本概念 Docker安装使用 Docker常用命令 Docker镜像构建 Docker本地仓 ...
- CF1009F Dominant Indices(启发式合并)
You are given a rooted undirected tree consisting of nn vertices. Vertex 11 is the root. Let's denot ...
- 矩阵解压,网络流UESTC-1962天才钱vs学霸周2
天才钱vs学霸周2 Time Limit: 500 MS Memory Limit: 128 MB Submit Status 由于上次的游戏中学霸周输了,因此学霸周想出个问题为难天才钱,问题 ...
- CSU OJ2151 集训难度
小L正在组织acm暑假集训,但众所周知,暑假集训的萌新中有OI神犇,也有暑假才开始学算法的萌新,如果统一集训的难度,无法很好地让萌新们得到训练,所以小L想了一个办法,根据每次测试的情况,改变萌新们的集 ...
- node+express 配置安装以及数据解析,cookie,session
一.express安装,创建服务 (1)安装:npm install express --save(2)创建服务 server.js: const express = require('express ...
- harbor客户端证书问题
自己搭了个harbor来托管private docker image,按照官方的教程非常顺利,最后通过jenkins打包后push docker image 的时候发现证书信任有问题了 Error r ...
- static介绍、内部类、final、权限修饰符的作用范围
static 关键字:(可用于修饰方法.变量) static 特点: static是静态修饰符,一般修饰成员变量.被static修饰的属于全局共享.被static修饰的成员属于 ...
- 解压小游戏之打砖块(C#+unity)
z这个小游戏很简洁,很简单,非常适合一个人玩,特别减压