事件点击
<button @click='downloadModelUrl'>下载模板</button>
<script lang='ts'>
import { TEMPLATE_URL } from 'src/framework/common/const';
import { download } from 'mwrComponents/util/tool'
private downloadModelUrl () {
download( TEMPLATE_URL[TaskType.fastScan])
}
</script>
额外引入文件
export function download(blobUrl,filname = ''){
let a = document.createElement('a');
blobUrl = encodeURI(blobUrl);
if (a.click && ('download' in a)) {
a.href = blobUrl;
a.download = filename;
a.target = '_parent';
(document.body || document.documentElement).appendChild(a);
a.click();
a.parentNode.removeChild(a);
return true;
}
window.open(blobUrl,'_parent');
}
export const TEMPLATE_URL = {
[TaskType.fastScan]:`${baseRootPrefix}static/vulnerability/import_demo_web_weak.xls`
}