需求1:前端提交表单时附件跟着一起发送给后台
需求2:前台获取后台附件
我这里并没有使用扩展组件,都是官方API
//前端代码
<view >
<wt-button type="primary" @click="openFile">上传附件</wt-button>
</view>
//显示图片名称 currentFilesPath-数组文件/单个文件 、previewFile-预览文件
<view>
<scroll-view scroll-y>
<view>
<view v-for="(file, index) in currentFilesPath">
<text @click='previewFile(file.path,file.type)'>{
{
(index + 1) + '、' + file.name}}</text>
<icon :type="iconType" style="margin-left: 20px;" size="20" @click="deleteFile(index)" />//图标,可有可无,我这个图标含义是删除对文件。
</view>
</view>
</scroll-view>
</view>
选择文件
openFile() {
uni.chooseFile({
count: 10