上面是 vue 的代码然而其余的都差不多
<script>
export default{
methods:{win_open(){window.open('result.csv','_self');
},
hidden_a_download(){
// 这种写起来很古典,全是 DOM 操作
let link = document.createElement('a');
link.style.display = 'none';
link.href = 'result.csv';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
}
</script>
<template>
<button @click="win_open()">windows open download</button>
<a href="result.csv"><button>a href download</button></a>
<button @click="hidden_a_download()">hidden a href download</button>
</template>