Giter Site home page Giter Site logo

vue-uploader's Introduction

Picture uploader - Vue2.X

将之前项目中使用到的一个文件上传组件提取出来,单独做一个图片上传组件 (虽然现在有许多功能齐全的上传组件,但是由于关乎程序大小和精简化,所以自己做一个简化的上传组件)

预览图

忽略图片的内容,因为都是表情包

How to start

  • 下载依赖项/install dependencies

npm install

  • 运行服务/run server

npm run test

  • 程序默认运行在3000端口: localhost:3000

Description

在全局注册或者局部注册完成后使用组件:

<uploader :src="'/api/imgs'"></uploader>

(该组件源码为components文件夹下面的uploader.vue文件, 其余文件是搭建了一个简易的框架和后端配置(为了测试上传进度))

  • Props:

    src - 后台文件上传的地址, 在Demo中就是 '/api/imgs'

  • 选取图片:

    支持PC端多选,如果移植到移动端根据各机型不同可能有差异

  • 图片预览:

    选取图片后,脚本会将图片转成BASE64格式并传给img标签显示

  • 上传

    当点击上传按钮时,将会遍历所有选中的文件,并添加到自定义的FormData中, 代码如下:

const formData = new FormData()
this.files.forEach((item) => {
	formData.append(item.name, item.file)
})

上传的时候上传进度将会已百分比以及进度条的形式显示在上传按钮的右边

License

MIT

vue-uploader's People

Contributors

akira0705 avatar watson-yan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vue-uploader's Issues

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.