更新记录

无(2021-02-02)


平台兼容性

Vue2 Vue3
×
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
app-vue ×
钉钉小程序 快手小程序 飞书小程序 京东小程序
× × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari

完整示例可导入示例项目运行

不要期待更新,我很懒~

希望能帮到你!


使用说明

属性 是否必填 值类型 返回值 说明
@up-success CallBack {name,data} 上传成功回调

ref调用

作用 方法 传入参数类型 说明
下载 download <URL,type> type='local'为保存到本地,默认为获取临时路径
预览 open URL 预览文件
上传 upload Object 上传文件

vue:

<l-file 
    ref="lFile" 
    @up-success="upSuccess"
></l-file>

js:

import lFile from '@/components/l-file/l-file.vue'
components:{lFile}

  • 函数说明
/* 预览临时文件 */
this.$refs.lFile.download(url)
.then(path=>{
    this.$refs.lFile.open(path);
});

/* 保存到本地 */
this.$refs.lFile.download(url,'local')
.then(path=>{
    this.localPath = path;
});

/* 
选择文件并上传

currentWebview=当前窗口,仅app端需要传,且必传

url=上传服务器地址,必填
name=上传文件的key(选填,默认为file)
header=请求头(选填)
*/
this.$refs.lFile.upload({
    // #ifdef APP-PLUS
    currentWebview: this.$mp.page.$getAppWebview(),
    // #endif
    url: 'https://www.example.com/upload', //测试地址,记得更换
    name: 'file',
    //header: {'Content-Type':'类型','Authorization':'token'},
    //...其他参数
});
<!-- 在原作者插件上加了H5 上传文件 -->

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

原插件地址 https://ext.dcloud.net.cn/plugin?id=1015

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问