npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

colipu-vue-ele-upload-file

v0.0.4

Published

对 element-ui upload 组件进一步封装, 使其更简单、易用

Downloads

3

Readme

vue-ele-upload-file | 使 element-ui upload 组件更简单、好用

license npm size download

image

安装

npm install vue-ele-upload-file --save

用法

import EleUploadFile from 'vue-ele-upload-file'

export default {
  components: {
    EleUploadFile
  }
}

示例

简单用法

<template>
  <ele-upload-file
    :responseFn="handleResponse"
    action="https://jsonplaceholder.typicode.com/posts/"
    v-model="file"
  />
</template>
<script>
  export default {
    data() {
      return {
        file: []
      }
    },
    methods: {
      // 对请求结果处理, 返回对象
      handleResponse(response, file) {
        return {
          url: URL.createObjectURL(file.raw),
          name: file.name,
          size: file.size
        }
      }
    }
  }
</script>

增加属性

<template>
  <ele-upload-file
    :disabled="false"
    :file-type="['doc', 'pdf', 'png', 'jpeg', 'jpg']"
    :fileSize="2"
    :isCanDelete="true"
    :isCanDownload="true"
    :isCanUploadSame="true"
    :isShowSize="true"
    :isShowTip="true"
    :limit="6"
    :multiple="true"
    :responseFn="handleResponse"
    action="https://jsonplaceholder.typicode.com/posts/"
    placeholder="上传附件"
    v-model="file"
  />
</template>

Props 参数

  props: {
    // 值
    value: [String, Object, Array],
    // 必选参数,上传的地址
    // 同 element-ui upload 组件
    action: {
      type: String,
      required: true
    },
    // 大小限制(MB)
    fileSize: Number,
    // 响应处理函数
    responseFn: Function,
    // 文件类型, 例如['png', 'jpg', 'jpeg']
    fileType: Array,
    // 提示
    placeholder: String,
    // 是否禁用
    disabled: Boolean,
    // 是否显示文件大小
    isShowSize: {
      type: Boolean,
      default: true
    },
    // 是否显示下载
    isCanDownload: {
      type: Boolean,
      default: true
    },
    // 是否可删除
    isCanDelete: {
      type: Boolean,
      default: true
    },
    // 是否可上传相同文件
    isCanUploadSame: {
      type: Boolean,
      default: true
    },
    // 是否显示提示
    isShowTip: {
      type: Boolean,
      default: true
    },
    // 设置上传的请求头部
    // 同 element-ui upload 组件
    headers: Object,
    // 是否支持多选文件
    // 同 element-ui upload 组件
    multiple: {
      type: Boolean,
      default: true
    },
    // 上传时附带的额外参数
    // 同 element-ui upload 组件
    data: Object,
    // 上传的文件字段名
    // 同 element-ui upload 组件
    name: {
      type: String,
      default: 'file'
    },
    // 支持发送 cookie 凭证信息
    // 同 element-ui upload 组件
    withCredentials: {
      type: Boolean,
      default: false
    },
    // 接受上传的文件类型
    // 同 element-ui upload 组件
    accept: String,
    // 最大允许上传个数
    // 同 element-ui upload 组件
    limit: Number
  },

事件

| 事件名称 | 说明 | 回调参数 | | -------- | ------------------ | ---------------- | | remove | 当文件被删除时触发 | (file, fileList) | | success | 文件上传成功时触发 | (file, fileList) | | error | 上传失败时触发 | (error) |

相关链接