# 全局的組件如何使用
```
<wl-upload-oss-files
:severType="other"
:maxNum="2"
:beforeUploadFilter="uploadFilter"
v-model="defaultStringList"
>
</wl-upload-oss-files>
```
### wlUploadFiles props
| 屬性 | 說明 | 類型 | 默認值 |
| --- | --- | --- | --- |
| fileName | 上傳文件的名字 | String | rand,md5(base64之后md5命名),origin(和文件名一至) |
| fileDir | 上傳文件的路徑 | String | wl |
| maxNum | 最多傳遞幾張圖片 | Number | 5 |
| uploadStyle | 上傳圖片還是其他(other) | String | 'image' |
| maxNumMessage |提示的文字信息 | String | |
| resultFiltration |返回格式 | Boolean | 默認false,result回調返回的是數組[{...,url:'...'}] ,為true的時候返回的是字符串的圖片地址,多個用逗號分割|
| maxSize | 圖片最大限制 | Number| 2048 |
| format| 上傳類型 | Array| ['jpg', 'jpeg', 'png'] |
| uploadUrl| 上傳的地址>=0.3.5 | String| http://house.wanglanglang.com |
| getSignUrl| hadoop的獲取簽名地址 | String|/api/ac/dangan/getHadoopService/getSign |
| uploadType| 上傳的方式 | String| 默認:oss,有:oss,php,hadoop
| beforeUploadFilter| 上傳前對文件進行驗證的函數 | Function|
### Upload methods
| 方法名 | 說明 | 參數 |
| --- | --- | --- |
| clear | 清空已上傳的文件列表(清空的時候也需要把默認顯示的內容清空)>=0.3.6 | 無 |
> 增加v-model 雙向綁定,直接返回上傳的字符串,如果是多個圖片或者文件用“,“分隔開
> 如果用hadoop上傳方式必須傳遞uploadUrl 上傳的地址,上傳的參數必須是
```
{
"filePath":"aaaa",
"fileName":"紅海灘景區智慧旅游20150423(云瑞).docx",
"file":"/9j/4S/....
}
```
> 返回的數據格式必須是如下:
```
{errcode: "0",data:'....png',errmsg:'success'}
```
>beforeUploadFilter 函數說明
```
uploadFilter (file, uploadList) {
let isExit = false
if (uploadList.length > 0) {
uploadList.forEach(item => {
if (item.url.indexOf(file.name) !== -1) {
isExit = true
}
})
}
if (isExit) {
this.$Notice.warning({
title: file.name + '【文件已經存在】',
duration: 0
})
return { errcode: false, selfShow: true }
}
let arr = file.name.split('.')
let arr2 = arr[0].split('-')
if (arr2.length !== 4) {
this.$Notice.warning({
title: file.name,
desc: '文件命名格式不正確必須全部是數字包含三個"-"',
duration: 0
})
return { errcode: false, selfShow: true }
}
if (parseInt(arr2[0]) < 1 || parseInt(arr2[0]) > 10 || !this.$common.xeUtils.isInteger(parseInt(arr2[0]))) {
this.$Notice.warning({
title: file.name + '【文件一級類別不正確】',
duration: 0
})
return { errcode: false, selfShow: true }
}
if (parseInt(arr2[1]) < 1 || parseInt(arr2[1]) > 10 || !this.$common.xeUtils.isInteger(parseInt(arr2[1]))) {
this.$Notice.warning({
title: file.name + '【文件二級類別不正確】',
duration: 0
})
return { errcode: false, selfShow: true }
}
if (parseInt(arr2[2]) < 1 || parseInt(arr2[2]) > 10 || !this.$common.xeUtils.isInteger(parseInt(arr2[2]))) {
this.$Notice.warning({
title: file.name + '【文件三級類別不正確】',
duration: 0
})
return { errcode: false, selfShow: true }
}
if (parseInt(arr2[3]) < 1 || parseInt(arr2[3]) > 100 || !this.$common.xeUtils.isInteger(parseInt(arr2[3]))) {
this.$Notice.warning({
title: file.name + '【文件四級類別不正確】',
duration: 0
})
return { errcode: false, selfShow: true }
}
return { errcode: true }
}
```
> return { errcode: false,errmsg:'文件名不對', selfShow: true }
> 如果errcode 是false 就不上傳文件提示errmsg的錯誤信息,如果selfShow傳遞true 不提示信息,自己寫提示代碼
- vue學習方向
- iview-admin項目說明
- 快速開始
- 開發工具
- 開始開發
- 接口的定義和調用
- 常用函數匯總
- 組件的定義
- iview開發規范說明
- 插件使用說明
- 時間插件
- 命名規范
- vue變量函數規則
- 接口嵌套使用說明
- 組件建立說明
- vue使用規范
- 數據檢測特別說名
- iview-layout-themes
- util
- common
- xeUtils詳細說明
- form表單自動生成
- theme1使用說明
- theme2使用說明
- hd-login登錄組件說明
- wl-upload-files圖片上傳組件
- wl-upload-imgs
- wl-upload-oss-files
- wl-read-excel
- wl-dir-upload選擇文件架
- system組件說明
- 機構管理wl-company-manager
- 用戶管理
- wl-excel-import Excel數據導入
- 前臺使用說明
- 后臺使用說明
- Excel使用說明
- wl-vue2-editor
- 字符串截取方法
- redis常用說明
- 推薦redis使用規范