<template>
<div id="app">
<el-button @click="openFile">下载文件</el-button>
<el-button @click="openImg">下载图片</el-button>
<router-view></router-view>
</div>
</template>
<script>
export default {
name: "App",
components: {},
data() {
return {};
},
methods: {
openFile() {
//word excel 下载项目种本地资源
//window.location = `${process.env.BASE_URL}static/大.xlsx`;
window.location = `${process.env.BASE_URL}static/静态文件.docx`;
},
openImg1() {
//下载图片 下载项目种本地资源
let request = new XMLHttpRequest();
let appUrl = `${window.location.protocol}//${window.location.host}/`;
request.responseType = "blob";
let url = appUrl + `${process.env.BASE_URL}static/1.png`;
request.open("GET", url);
request.onload = functio
vue前端获取项目下的静态资源文件夹中的文件并下载
于 2023-09-26 19:30:05 首次发布