根据文件后缀名 动态加载对应图片

该篇文章描述了一个IT系统中处理文件上传和展示的组件,使用了HTML和JavaScript代码片段。它展示了如何根据文件扩展名动态加载图片或视频,并使用线进度条跟踪文件上传进度。
摘要由CSDN通过智能技术生成

    <view @click="downloadFile(item,i)" class="customCard marginRight" v-if="item.contentsType =='FileUrl'||
                                        item.type=='file' || 
                                        item.contentsType=='FILE'">
                                        <view class="all">
                                            <view class="filePic">
                                                <video v-if="isVideo(item.ext.filename)" :src="item.ext.url"></video>
                                                <image v-else :src="getFileType(item.ext.filename)" mode="widthFix"></image>
                                            </view>
                                            <view class="Bottom" >
                                                <view class="fileName" v-if="!isVideo(item.ext.filename)">
                                                    {{item.ext.filename}}
                                                </view>
                                                <view class="fileSize" v-if="!isVideo(item.ext.filename)">
                                                    大小:{{formatFileSize(item.ext.fileSize) || '未知'}}
                                                </view>
                                            </view>
                                        </view>
                                        <view class="" style="padding: 0 20rpx;">
                                            <u-line-progress v-if="fileIndexes.includes(i)" height="6"
                                                :percentage="percentageValue[i]"
                                                activeColor="#19be6b"></u-line-progress>
                                        </view>

                                    </view>

  
 getFileType(e) {
                const ext = e.split('.').pop()
                if (["apk","exe", "mp3", "pdf", "ppt", "rar", "txt", "word", 'xls', "zip"].includes(
                    ext)) {
                    return require(`@/static/fileicon/${ext}.png`)
                } else if (['doc', 'dot', 'docx', 'rtf'].includes(ext)) {
                    return require('@/static/fileicon/word.png')
                } else if (['xlsx', 'xls'].includes(ext)) {
                    return require('@/static/fileicon/xls.png')
                } else if (['ppt', 'pptx'].includes(ext)) {
                    return require('@/static/fileicon/ppt.png')
                } else {
                    return require('@/static/fileicon/null.png')
                }
            },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值