马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- <el-button link type="success" icon="Download" @click="handleDownload(file)"> 附件下载 </el-button>
复制代码- function handleDownload(val) {
- const url = import.meta.env.VITE_APP_BASE_API + val // 本地地址加文件路径
- const link = document.createElement('a')
- link.href = url
- link.setAttribute('download', `附件_${new Date().getTime()}`)
- document.body.appendChild(link)
- link.click()
- document.body.removeChild(link)
- }
复制代码
- <uni-forms-item label="文件:" name="excelFilePathView">
- <uni-file-picker fileMediatype="all" v-model="form.excelFilePathView" @select="selectFilePath" />
- <view v-for="(file,index) in form.excelFilePathView" :key="index">
- <a style="color:#00aaff" :href="file.url" target="_blank"> 查看 {{ index+1 }}</a>
- </view>
- </uni-forms-item>
复制代码- selectFilePath(e) {
- const tempFilePaths = e.tempFilePaths
- const imgUrl = tempFilePaths[0]
- uni.uploadFile({
- url: config.baseUrl + "/common/upload",
- filePath: imgUrl,
- name: 'file',
- header: {
- "Authorization": 'Bearer ' + getToken()
- },
- success: (uploadFileRes) => {
- let path = JSON.parse(uploadFileRes.data)
- this.form.excelFilePathView.push({
- name: path.fileName,
- url: path.fileName
- })
- }
- })
- },
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!qidao123.com:ToB企服之家,中国第一个企服评测及软件市场,开放入驻,技术点评得现金 |