downLoad.vue
911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!--
* @Description: 页面提供插件下载
* @Autor: renchao
* @LastEditTime: 2023-06-13 15:49:55
-->
<template>
<div class='downLoad'>
<p>{{formData}}是否下载文件?</p>
<div>
<el-button @click="$popupCacel">取消</el-button>
<el-button type="primary" @click="handleDown">确定</el-button>
</div>
</div>
</template>
<script>
export default {
props: {
formData: {
type: Object,
default: {}
}
},
methods: {
handleDown () {
let a = document.createElement('a')
a.style.display = 'none'
a.setAttribute('download', 'bg.jpg')
// a.href = require('../../../../public/')
document.body.appendChild(a)
console.log('href', a.href)
a.click()
document.body.removeChild(a)
}
}
}
</script>
<style scoped lang='scss'>
@import "~@/styles/public.scss";
</style>