1.3.10 • Published 3 years ago

@niu_/vue-tools v1.3.10

Weekly downloads
98
License
MIT
Repository
github
Last release
3 years ago

一些插件

图片预览插件

使用

import VueTools from '@niu_/vue-tools';
import '@niu_/vue-tools/css/main.css'

Vue.use(VueTools);

单文件中可以通过组件 Preview 形式或者 this.$preview 访问

<Preview
    v-model="show"
    :img-list="imgList"
    :minus="false"
></Preview>
<button @click="show = !show">点击显示</button>
<button @click="handlePreview"></button>

<script>
import previewImg from './previewimg.png';

export default {
    data () {
        return {
            imgList: [
                {
                    id: 1,
                    url: previewImg
                },
                {
                    id: 2,
                    url: 'https://img.png'
                }
            ]
        }
    },
    methods: {
        handlePreview () {
            this.$preview.open({
                imgList: [
                    {
                        id: 1,
                        url: previewImg
                    }
                ],
                change: (params) => {
                    // params 包含了当前图片的基本信息及切换信息
                    // 例如 角度 缩放程度等
                }
            })
        }
    }
}
</script>

数据格式

id非必填;

通过脚本引入的使用方式和以上类似

API

属性说明类型默认值
left-rotate是否显示左旋转按钮booleantrue
right-rotate是否显示右边旋转按钮booleantrue
minus是否显示缩小按钮booleantrue
plus是否显示放大按钮booleantrue
reset是否显示重置按钮booleantrue
value(v-model)控制Preview组件的显隐boolean-
img-list显示的图片数组{ url: string; id?: number }-

事件

事件名称说明回调参数
close点击关闭按钮的回调false
change切换或者操作图片回调object

$preview

使用 this.$preview 的时候,可以通过open 方法打开预览

this.$preview.open({
    imgList: this.imgList,
    change: (params) => {
        // params 回调的参数
    },
    menuList: {
        leftRotate: false,
        // 控制菜单项
        // 同prop值
    }
})

通过 getContainer 可以指定挂载的节点

this.$preview.getContainer(() => document.querySelector('.container'))
    .open({
        imgList: this.imgList
    })

在线演示(暂时)

演示

1.3.10

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago