
简体中文
从本地选择文件
Web | 微信小程序 | Android | iOS |
---|---|---|---|
4.0 | 4.41 | 4.51 | x |
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | ChooseFileOptions | 是 | - | - | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tempFilePaths | Array<string> | 是 | - | - | 文件的本地文件路径列表, Android平台不支持 | |||||||||||||||||||||||||||||||||||||||||||||||||||
tempFiles | Array<ChooseFileTempFile> | 是 | - | - | 文件的本地文件列表,每一项是一个 File 对象 | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
errCode | number | 是 | - | - | 错误码 | |||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||
errSubject | string | 是 | - | - | 统一错误主题(模块)名称 | |||||||||||||||||||||||||||||||||
data | any | 否 | - | - | 错误信息中包含的数据 | |||||||||||||||||||||||||||||||||
cause | Error | 否 | - | - | 源错误信息,可以包含多个错误,详见SourceError | |||||||||||||||||||||||||||||||||
errMsg | string | 是 | - | - | - |
Template
Script
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1;">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<text style="margin: 2px; padding: 2px; border: 1px solid #000000;">{{ log }}</text>
<button class="btnstyle" type="primary" @tap="chooseVideo">选择文件(video) 单选</button>
<button class="btnstyle" type="primary" @tap="chooseVideoMul">选择文件(video) 多选</button>
<button class="btnstyle" type="primary" @tap="playVideo">选择文件(video)并播放</button>
<video class="video" :src="src" :controls="true"></video>
<button class="btnstyle" type="primary" @tap="chooseImage">选择文件(image) 单选</button>
<button class="btnstyle" type="primary" @tap="chooseImageMul">选择文件(image) 多选</button>
<button class="btnstyle" type="primary" @tap="viewImg">选择文件(image) 并预览</button>
<button class="btnstyle" type="primary" @tap="chooseAudio">选择文件(audio) 单选</button>
<button class="btnstyle" type="primary" @tap="chooseAudioMul">选择文件(audio) 多选</button>
<button class="btnstyle" type="primary" @tap="playAudio">选择文件(audio) 并播放</button>
<button class="btnstyle" type="primary" @tap='chooseAll'>选择文件(all) 单选</button>
<button class="btnstyle" type="primary" @tap='chooseAllMul'>选择文件(all) 多选</button>
<view style="height: 4px;"></view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<style>
.btnstyle {
margin: 4px;
}
.video {
align-self: center;
width: 300px;
height: 225px;
}
.uni-uploader__input-box {
margin: 5px;
width: 104px;
height: 104px;
border: 1px solid #D9D9D9;
}
</style>
Template
Script
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1;">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<text style="margin: 2px; padding: 2px; border: 1px solid #000000;">{{ log }}</text>
<button class="btnstyle" type="primary" @tap="chooseVideo">选择文件(video) 单选</button>
<button class="btnstyle" type="primary" @tap="chooseVideoMul">选择文件(video) 多选</button>
<button class="btnstyle" type="primary" @tap="playVideo">选择文件(video)并播放</button>
<video class="video" :src="src" :controls="true"></video>
<button class="btnstyle" type="primary" @tap="chooseImage">选择文件(image) 单选</button>
<button class="btnstyle" type="primary" @tap="chooseImageMul">选择文件(image) 多选</button>
<button class="btnstyle" type="primary" @tap="viewImg">选择文件(image) 并预览</button>
<button class="btnstyle" type="primary" @tap="chooseAudio">选择文件(audio) 单选</button>
<button class="btnstyle" type="primary" @tap="chooseAudioMul">选择文件(audio) 多选</button>
<button class="btnstyle" type="primary" @tap="playAudio">选择文件(audio) 并播放</button>
<button class="btnstyle" type="primary" @tap='chooseAll'>选择文件(all) 单选</button>
<button class="btnstyle" type="primary" @tap='chooseAllMul'>选择文件(all) 多选</button>
<view style="height: 4px;"></view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<style>
.btnstyle {
margin: 4px;
}
.video {
align-self: center;
width: 300px;
height: 225px;
}
.uni-uploader__input-box {
margin: 5px;
width: 104px;
height: 104px;
border: 1px solid #D9D9D9;
}
</style>
uni.getRecorderManager()
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | 错误信息 |