1.0.1 • Published 2 years ago

plug-in-components-asag v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

dl-preview

下载

npm install dl-preview --save 

全局导入

import DlPreview from 'dl-preview'
Vue.use(DlPreview)

按需导入

import { componentName } form 'dl-preview'
Vue.component(componentName)

Customize configuration

See Configuration Reference.

属性

属性名描述类型必填项默认值
fileList要预览的文件列表;propsArray[]
previewType预览方式(是否需要左侧树形目录,值为 tree 时表示需要左侧树形目录)Stringtree
download用于下载文件返回,要下载的文件信息Functionundefiled

fileList props

属性名描述类型必填项
id目录的唯一值String、Number
label目录的名称String
children目录中的文件列表Array
children.id文件的唯一值String、Number
children.label文件的名称String
children.type文件的类型 png, jpg, jpeg, image, mp3, audio, mp4, video, doc, docx, pdf, textString
children.url文件预览路径String
children.downloadPath文件下载路径String
children.docDownloadPath文件下载路径(弃用)String

方法

方法名描述参数返回值
show显示预览组件({ type, index, item }) => {};type: previewTypetree 时必传,值为文件所在目录的 id,String;index: 预览文件所在目录中的下标,Number;item: 要预览的文件信息,Objectnull
hide关闭预览组件() => {}null
handleAccordion折叠菜单栏 previewTypetree 时可用() => {}null
handleReset重新渲染 pdf() => {}null
handleRotate旋转图片(type) => {};type: left, rightnull
handlerPreviewPreFile上一页() => {}null
handlerPreviewNextFile下一页() => {}null
hanlderZoomIn缩小,图片和pdf可用() => {}null
hanlderZoomOut放大,图片和pdf可用() => {}null

使用

<template>
  <div>
    <dl-Preview ref="dl-preview" previewType="tree" :fileList="fileList" :download="download"></dl-Preview>
  </div>
</template>

<script>
export default {
  data() {
    return {
      fileList: [{
        id: '11',
        label: 'test',
        children: [
          {
            id: '123456',
            label: '3.0设备管理更改需求.png',
            type: 'png',
            url: 'http://127.0.0.1:8080/3.0设备管理更改需求.png',
            downloadPath: 'http://127.0.0.1:8080/3.0设备管理更改需求.png',
            fileType: "11",
          },
          {
            id: '123457',
            label: 'file_type_audio.png',
            type: 'png',
            url: 'http://127.0.0.1:8080/file_type_audio.png',
            downloadPath: 'http://127.0.0.1:8080/file_type_audio.png',
            fileType: "11",
          },
        ]
      }],
    }
  },
  mounted() {
    setTimeout(() => {
      this.$refs["dl-preview"].show({ type: '11', index: 1, item: this.fileList[0].children[1] });
    }, 3000)
  },
  methods: {
    download(file) {

    }
  }
}
</script>
1.0.1

2 years ago

1.0.0

2 years ago