Coder Social home page Coder Social logo

wc-view's Introduction

wc-view

移动端图片浏览插件.

演示地址

演示地址

安装

npm i wc-view --save-dev

使用

import wcView from 'wc-view';
import 'wc-view/style.css';
Vue.use(wcView);
img 标签时: 
<img class="wc-preview-img" :src="url" v-for="(url, key) in list" :key="key" @click="$preview($event, list, key)">

如果 list 是一个对象数组的时候,
需要额外为 $preview 传递一个参数, 用于标记对象里哪一个字段是图片 url;
<img class="wc-preview-img" :src="item.img" v-for="(item, key) in list" :key="key" @click="$preview($event, list, key,'img')">

背景图时:
<div v-for="(url, key) in list" :key="key" @click="$preview($event, list, key)">

配置选项

showCloseBtn: 是否显示关闭按钮, 默认为 true // $preview($event, list, key, '', {showCloseBtn: false})

img 和 背景图之间的区别:

  • img的查看效果, 图片带一个放大效果; 而背景图不带;
  • 为 img 设置大小的时候, 可能会显示变形, 而背景图可以通过 background-size 保持图片 显示正常;
  • 需要额外的为 img 标签加上一个 wc-perview-img class, 为的是放大效果正常显示;

其他

  • 压缩之后在 10k 左右;
  • 默认的图片显示方式是宽度优先, 高度会按比例缩放;(一般情况下图片的宽度会被变成 100% 屏幕宽度)
  • 支持 pagination;

项目地址

wc-view;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.