Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit ce42d16

Browse files
committed
init
0 parents  commit ce42d16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+12395
-0
lines changed

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
# local env files
6+
.env.local
7+
.env.*.local
8+
9+
# Log files
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
14+
# Editor directories and files
15+
.idea
16+
.vscode
17+
*.suo
18+
*.ntvs*
19+
*.njsproj
20+
*.sln
21+
*.sw?

.npmignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
node_modules
2+
tests
3+
docs
4+
documentation
5+
public
6+
vue.config.js
7+
coverage
8+
jest.config.js
9+
.eslintrc.js
10+
cypress.json
11+
postcss.config.js
12+
babel.config.js
13+
.editorconfig
14+
.cypress.json
15+
dist/demo.html
16+
.browserslistrc

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 二当家的
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# vue-ele-upload-file | 使 element-ui upload 组件更简单、好用
2+
3+
[![license](https://img.shields.io/npm/l/vue-ele-upload-file.svg)](https://dream2023.github.io/vue-ele-upload-file/)
4+
[![npm](https://img.shields.io/npm/v/vue-ele-upload-file.svg)](https://www.npmjs.com/package/vue-ele-upload-file)
5+
[![size](https://img.shields.io/bundlephobia/minzip/vue-ele-upload-file.svg)](https://www.npmjs.com/package/vue-ele-upload-file)
6+
[![download](https://img.shields.io/npm/dw/vue-ele-upload-file.svg)](https://npmcharts.com/compare/vue-ele-upload-file?minimal=true)
7+
8+
![image](https://raw.githubusercontent.com/dream2023/images/master/vue-ele-upload-file.17yo68suvvo.gif)
9+
10+
## 安装
11+
12+
```bash
13+
npm install vue-ele-upload-file --save
14+
```
15+
16+
### 用法
17+
18+
```js
19+
import EleUploadFile from 'vue-ele-upload-file'
20+
21+
export default {
22+
components: {
23+
EleUploadFile
24+
}
25+
}
26+
```
27+
28+
## 示例
29+
30+
### 简单用法
31+
32+
```html
33+
<template>
34+
<ele-upload-file
35+
:responseFn="handleResponse"
36+
action="https://jsonplaceholder.typicode.com/posts/"
37+
v-model="file"
38+
/>
39+
</template>
40+
<script>
41+
export default {
42+
data() {
43+
return {
44+
file: []
45+
}
46+
},
47+
methods: {
48+
// 对请求结果处理, 返回对象
49+
handleResponse(response, file) {
50+
return {
51+
url: URL.createObjectURL(file.raw),
52+
name: file.name,
53+
size: file.size
54+
}
55+
}
56+
}
57+
}
58+
</script>
59+
```
60+
61+
### 增加属性
62+
63+
```html
64+
<template>
65+
<ele-upload-file
66+
:disabled="false"
67+
:file-type="['doc', 'pdf', 'png', 'jpeg', 'jpg']"
68+
:fileSize="2"
69+
:isCanDelete="true"
70+
:isCanDownload="true"
71+
:isCanUploadSame="true"
72+
:isShowSize="true"
73+
:isShowTip="true"
74+
:limit="6"
75+
:multiple="true"
76+
:responseFn="handleResponse"
77+
action="https://jsonplaceholder.typicode.com/posts/"
78+
placeholder="上传附件"
79+
v-model="file"
80+
/>
81+
</template>
82+
```
83+
84+
## Props 参数
85+
86+
```js
87+
props: {
88+
//
89+
value: [String, Object, Array],
90+
// 必选参数,上传的地址
91+
// 同 element-ui upload 组件
92+
action: {
93+
type: String,
94+
required: true
95+
},
96+
// 大小限制(MB)
97+
fileSize: Number,
98+
// 响应处理函数
99+
responseFn: Function,
100+
// 文件类型, 例如['png', 'jpg', 'jpeg']
101+
fileType: Array,
102+
// 提示
103+
placeholder: String,
104+
// 是否禁用
105+
disabled: Boolean,
106+
// 是否显示文件大小
107+
isShowSize: {
108+
type: Boolean,
109+
default: true
110+
},
111+
// 是否显示下载
112+
isCanDownload: {
113+
type: Boolean,
114+
default: true
115+
},
116+
// 是否可删除
117+
isCanDelete: {
118+
type: Boolean,
119+
default: true
120+
},
121+
// 是否可上传相同文件
122+
isCanUploadSame: {
123+
type: Boolean,
124+
default: true
125+
},
126+
// 是否显示提示
127+
isShowTip: {
128+
type: Boolean,
129+
default: true
130+
},
131+
// 设置上传的请求头部
132+
// 同 element-ui upload 组件
133+
headers: Object,
134+
// 是否支持多选文件
135+
// 同 element-ui upload 组件
136+
multiple: {
137+
type: Boolean,
138+
default: true
139+
},
140+
// 上传时附带的额外参数
141+
// 同 element-ui upload 组件
142+
data: Object,
143+
// 上传的文件字段名
144+
// 同 element-ui upload 组件
145+
name: {
146+
type: String,
147+
default: 'file'
148+
},
149+
// 支持发送 cookie 凭证信息
150+
// 同 element-ui upload 组件
151+
withCredentials: {
152+
type: Boolean,
153+
default: false
154+
},
155+
// 接受上传的文件类型
156+
// 同 element-ui upload 组件
157+
accept: String,
158+
// 最大允许上传个数
159+
// 同 element-ui upload 组件
160+
limit: Number
161+
},
162+
```
163+
164+
## 相关链接
165+
166+
- [element-ui upload 组件](https://element.eleme.cn/#/zh-CN/component/upload)

babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/app'
4+
]
5+
}

example/App.vue

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<div style="max-width: 800px;margin: 50px auto">
3+
<ele-upload-file
4+
:disabled="false"
5+
:file-type="['svg', 'html', 'js', 'css', 'doc', 'xls', 'zip']"
6+
:fileSize="0.2"
7+
:isCanDelete="true"
8+
:isCanDownload="true"
9+
:isCanUploadSame="true"
10+
:isShowSize="true"
11+
:isShowTip="true"
12+
:limit="6"
13+
:multiple="false"
14+
:responseFn="handleResponse"
15+
action="https://jsonplaceholder.typicode.com/posts/"
16+
placeholder="上传附件"
17+
v-model="file"
18+
/>
19+
</div>
20+
</template>
21+
<script>
22+
export default {
23+
data() {
24+
return {
25+
file: []
26+
}
27+
},
28+
methods: {
29+
handleResponse (response, file) {
30+
return {
31+
url: URL.createObjectURL(file.raw),
32+
name: file.name,
33+
size: file.size
34+
}
35+
}
36+
}
37+
}
38+
</script>

example/main.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Vue from 'vue'
2+
import App from './App.vue'
3+
import ElementUI from 'element-ui'
4+
import 'element-ui/lib/theme-chalk/index.css'
5+
import EleUploadFile from '../lib/index'
6+
7+
Vue.config.productionTip = false
8+
Vue.use(ElementUI)
9+
Vue.component('ele-upload-file', EleUploadFile)
10+
11+
new Vue({
12+
render: h => h(App)
13+
}).$mount('#app')

0 commit comments

Comments
 (0)