https://github.com/xd-tayde/wepy-upload
the upload module of wepy.
https://github.com/xd-tayde/wepy-upload
compress image image-upload wepy wepy-upload
Last synced: 5 months ago
JSON representation
the upload module of wepy.
- Host: GitHub
- URL: https://github.com/xd-tayde/wepy-upload
- Owner: xd-tayde
- Created: 2018-04-26T07:42:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-11T07:03:11.000Z (almost 8 years ago)
- Last Synced: 2025-04-10T02:48:42.713Z (about 1 year ago)
- Topics: compress, image, image-upload, wepy, wepy-upload
- Size: 10.7 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wepy-upload -- 小程序上传组件
## 简介:
包含功能:
1. 安卓/IOS统一图片选择控件(样式/功能);
2. 自定义相机功能: 使用前置摄像头,前置拍照后图片翻转;
3. 图片压缩功能并可自定义尺寸;
4. 图片上传;
## 更新
- 1.0.3
- 修复错误提示语法错误;
- 优化文档说明;
## 使用姿势:
1. 引用:
`import MTUpload from 'wepy-upload'`;
2. 添加 `components`:
`components = { MTUpload }`;
3. `template` 中使用:
```html
```
## 详细属性与事件
- uploadConfig: 图片上传配置,缺省时不进行上传
- type: Object
- default: {}
```js
uploadConfig: {
// 上传地址;
api: {
token: 'url',
upload: 'url',
},
// 上传地址拼接;
dataToImageUrl(data) {
return imageUrl;
},
}
```
- useCustomizedCamera: 是否使用自定义相机;
- type: Boolean
- default: false
- uploadId: 组件id,会在success中原样传出,可用于标识
- type: Number
- default: 0
- bg: 按钮背景
- type: String
- default: ''
- text: 按钮文案;
- type: String,
- default: '',
- imageSpaceLimit: 上传图片大小限制;
- type: String,
- default: '10mb',
- imageSizeLimit: 上传图片压缩尺寸;
- type: Number,
- default: 800,
- imageQuality: 图片压缩比例;
- type: Number,
- default: 0.9,
- modelPhotoText: 底部弹窗相机文案;
- type: String,
- default: '拍照',
- modelAlbumText: 底部弹窗相册文案;
- type: String,
- default: '从手机相册选择',
- modelHideText: 底部弹窗取消文案;
- type: String,
- default: '取消',
### 事件
- @tap.user: 按钮点击时触发;
- params: 无
- @start.user: 上传开始
- filePath: 图片临时路径
- @compress.user: 压缩后的图片
- path: 图片临时路径
- width: 图片宽度
- height: 图片高度
- compressTime: 压缩耗时
- @success.user: 图片选择成功;
- data: 服务端接口返回数据;
- image: 图片路径
- width: 图片宽度
- height: 图片高度
- uploadId: 组件id
- uploadTime: 上传耗时
- @fail.user: 图片选择失败;
- error: 错误对象;
- type: 错误类型;
- msg: 错误提示语;