Skip to content

Commit 64497e2

Browse files
committed
【vue-file-upload】 1.修改babel-loader 版本问题;2.修改按钮名称为slot,用户自己定制
1 parent 11768dc commit 64497e2

File tree

5 files changed

+38
-57
lines changed

5 files changed

+38
-57
lines changed

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ vue2.x版本 可安装当前最新版本
88
vue.js ,vue-loader 上传文件,vue-file-upload
99
代码里面包含demo,运行:
1010
```shell
11-
npm run dev
11+
yarn install && yarn sart
1212
```
1313

1414
## install
@@ -19,7 +19,8 @@ npm install --save vue-file-upload
1919
### CommonJS
2020
```javascript
2121
var VueFileUpload = require('vue-file-upload');
22-
22+
//es6
23+
import VueFileUpload from '../src/vue-file-upload.vue';
2324
```
2425
### 属性(Props)
2526
```javascript
@@ -33,21 +34,11 @@ max:{
3334
type:Number,
3435
default:Number.MAX_VALUE
3536
},
36-
//按钮名称
37-
label:{
38-
type:String,
39-
default:'选择文件'
40-
},
4137
//文件名称(服务端识别的上传文件名)
4238
name:{
4339
type:String,
4440
default:'file'
4541
},
46-
//图标
47-
icon:{
48-
type:String,
49-
default:null
50-
},
5142
//自动上传
5243
autoUpload:{
5344
type:Boolean,
@@ -98,6 +89,13 @@ events:{
9889
}
9990
}
10091

92+
```
93+
### 按钮名称说明
94+
```html
95+
<vue-file-upload>
96+
<span slot="label">上传文件</span>
97+
</vue-file-upload>
98+
10199
```
102100
### 文件属性说明(file)
103101
```javascript
@@ -136,6 +134,7 @@ vue-file-upload(url='upload.do',
136134
v-bind:events = 'cbEvents',
137135
v-bind:request-options = "reqopts",
138136
v-on:onAdd = "onAddItem")
137+
span(slot="label") 选择文件
139138
table
140139
thead
141140
tr

demo/app.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ div
3838
v-bind:request-options = "reqopts",
3939
v-on:onAdd = "onAddItem"
4040
)
41+
span(slot="label") 选择文件
4142
table
4243
thead
4344
tr

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"license": "MIT",
2424
"devDependencies": {
2525
"babel-core": "^6.26.0",
26-
"babel-loader": "7.7.1",
26+
"babel-loader": "6.2.7",
2727
"babel-plugin-transform-runtime": "^6.8.0",
2828
"babel-preset-env": "^1.6.0",
2929
"babel-preset-stage-2": "^6.24.1",

src/vue-file-upload.vue

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template>
22
<span class="vue-file-upload">
3-
<i v-if='icon != null' v-bind:class='rendIcon'></i>
4-
{{label}}
3+
<slot name="label">上传文件</slot>
54
<input ref="fileInput" type="file" name="file">
65
</span>
76
</template>
@@ -13,9 +12,7 @@
1312
* 带来的问题也有很多:比如队列文件的同步
1413
* @param {String:url} [上传图片地址]
1514
* @param {Number:max} [上传图片数量]
16-
* @param {String:label} [按钮显示名称]
1715
* @param {String:name} [上传图片name属性]
18-
* @param {String:icon} [图标class]
1916
* @param {Boolean:autoUpload} [自动上传:true:是,false:否]
2017
* @param {Boolean:multiple} [多文件上传:true:是,false:否]
2118
* @param {Array:files} [多文件队列,通常需要和开发组件双向绑定]
@@ -38,18 +35,10 @@ export default{
3835
type:Number,
3936
default:Number.MAX_VALUE
4037
},
41-
label:{
42-
type:String,
43-
default:'选择文件'
44-
},
4538
name:{
4639
type:String,
4740
default:'file'
4841
},
49-
icon:{
50-
type:String,
51-
default:null
52-
},
5342
autoUpload:{
5443
type:Boolean,
5544
default:false
@@ -100,9 +89,6 @@ export default{
10089
}
10190
},
10291
computed:{
103-
rendIcon(){
104-
return this.icon.split(/\s/g);
105-
},
10692
bFiles:{
10793
get(){
10894
return this.files;

yarn.lock

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,14 @@ babel-helpers@^6.24.1:
393393
babel-runtime "^6.22.0"
394394
babel-template "^6.24.1"
395395

396-
babel-loader@7.7.1:
397-
version "7.1.1"
398-
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.1.tgz#b87134c8b12e3e4c2a94e0546085bc680a2b8488"
396+
babel-loader@6.2.7:
397+
version "6.2.7"
398+
resolved "http://registry.npm.taobao.org/babel-loader/download/babel-loader-6.2.7.tgz#16fdbf64328030dc5a606827d389c8b92a2a8032"
399399
dependencies:
400-
find-cache-dir "^1.0.0"
401-
loader-utils "^1.0.2"
400+
find-cache-dir "^0.1.1"
401+
loader-utils "^0.2.11"
402402
mkdirp "^0.5.1"
403+
object-assign "^4.0.1"
403404

404405
babel-messages@^6.23.0:
405406
version "6.23.0"
@@ -1868,13 +1869,13 @@ finalhandler@~1.0.4:
18681869
statuses "~1.3.1"
18691870
unpipe "~1.0.0"
18701871

1871-
find-cache-dir@^1.0.0:
1872-
version "1.0.0"
1873-
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f"
1872+
find-cache-dir@^0.1.1:
1873+
version "0.1.1"
1874+
resolved "http://registry.npm.taobao.org/find-cache-dir/download/find-cache-dir-0.1.1.tgz#c8defae57c8a52a8a784f9e31c57c742e993a0b9"
18741875
dependencies:
18751876
commondir "^1.0.1"
1876-
make-dir "^1.0.0"
1877-
pkg-dir "^2.0.0"
1877+
mkdirp "^0.5.1"
1878+
pkg-dir "^1.0.0"
18781879

18791880
find-up@^1.0.0:
18801881
version "1.1.2"
@@ -1883,7 +1884,7 @@ find-up@^1.0.0:
18831884
path-exists "^2.0.0"
18841885
pinkie-promise "^2.0.0"
18851886

1886-
find-up@^2.0.0, find-up@^2.1.0:
1887+
find-up@^2.0.0:
18871888
version "2.1.0"
18881889
resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"
18891890
dependencies:
@@ -2580,22 +2581,22 @@ loader-runner@^2.3.0:
25802581
version "2.3.0"
25812582
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2"
25822583

2583-
loader-utils@^1.0.2, loader-utils@^1.1.0:
2584-
version "1.1.0"
2585-
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.1.0.tgz#c98aef488bcceda2ffb5e2de646d6a754429f5cd"
2584+
loader-utils@^0.2.11, loader-utils@~0.2.5:
2585+
version "0.2.17"
2586+
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348"
25862587
dependencies:
25872588
big.js "^3.1.3"
25882589
emojis-list "^2.0.0"
25892590
json5 "^0.5.0"
2591+
object-assign "^4.0.1"
25902592

2591-
loader-utils@~0.2.5:
2592-
version "0.2.17"
2593-
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348"
2593+
loader-utils@^1.0.2, loader-utils@^1.1.0:
2594+
version "1.1.0"
2595+
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.1.0.tgz#c98aef488bcceda2ffb5e2de646d6a754429f5cd"
25942596
dependencies:
25952597
big.js "^3.1.3"
25962598
emojis-list "^2.0.0"
25972599
json5 "^0.5.0"
2598-
object-assign "^4.0.1"
25992600

26002601
locate-path@^2.0.0:
26012602
version "2.0.0"
@@ -2658,12 +2659,6 @@ macaddress@^0.2.8:
26582659
version "0.2.8"
26592660
resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12"
26602661

2661-
make-dir@^1.0.0:
2662-
version "1.0.0"
2663-
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.0.0.tgz#97a011751e91dd87cfadef58832ebb04936de978"
2664-
dependencies:
2665-
pify "^2.3.0"
2666-
26672662
map-obj@^1.0.0, map-obj@^1.0.1:
26682663
version "1.0.1"
26692664
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d"
@@ -3137,7 +3132,7 @@ performance-now@^0.2.0:
31373132
version "0.2.0"
31383133
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5"
31393134

3140-
pify@^2.0.0, pify@^2.3.0:
3135+
pify@^2.0.0:
31413136
version "2.3.0"
31423137
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
31433138

@@ -3155,11 +3150,11 @@ pinkie@^2.0.0:
31553150
version "2.0.4"
31563151
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
31573152

3158-
pkg-dir@^2.0.0:
3159-
version "2.0.0"
3160-
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b"
3153+
pkg-dir@^1.0.0:
3154+
version "1.0.0"
3155+
resolved "http://registry.npm.taobao.org/pkg-dir/download/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4"
31613156
dependencies:
3162-
find-up "^2.1.0"
3157+
find-up "^1.0.0"
31633158

31643159
portfinder@^1.0.9:
31653160
version "1.0.13"

0 commit comments

Comments
 (0)