ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[toc] ### 1. 给下载按钮添加点击事件和方法 ### 2. 实现文件下载功能 ``` <Button icon="ios-search" class="mr-2" v-if="checkedCount" @click="downloadAll">下载</Button> <Tooltip v-if="!item.isdir" content="下载" placement="bottom"> <Icon type="md-cloud-download" size="18" class="mx-2" style="cursor: pointer;" @click="download"/> </Tooltip> download(){ this.$emit('on-event',{ type:"download", item:this.item, }) }, case 'download': this.download(e.item.url,e.item.name) downloadAll(){ this.checkList.forEach(item=>{ if(!item.isdir){ this.download(item.url,item.name) } }) }, // 下载 download(url,name){ url = url.replace('http://demo-mp3.oss-cn-shenzhen.aliyuncs.com','/oss') this.axios.get(url,{ responseType:"blob" }).then(data=>{ if(!data){ return } let url = window.URL.createObjectURL(new Blob([data])) let link = document.createElement('a') link.style.display = 'none' link.href = url link.setAttribute('download',name) document.body.appendChild(link) link.click() }) }, ```