Мне нужно скачать файлы с удаленного API по ссылке vue-router
. Remote api возвращает файлы в base64
.
Я добавляю маршрут:
const router = new VueRouter({
mode: 'history',
routes: [
{ path: '/files/:id', name: 'file', component: Vue.component('vue-file'), props: true }
],
});
и добавляю для него компонент:
<template>
<div>
</div>
</template>
<script>
export default {
name: 'file',
props: {
id: String
},
mounted: function() {
this.download();
},
methods: {
download: function() {
let $this = this;
axios
.get('apiurl' + encodeURIComponent(this.id))
.then(function (response) {
download(response.data.base64content)
});
}
}
}
</script>
Работает, но я нетхочу показать шаблон компонента <template><div></div></template>
. Я даже не хочу обновлять содержимое на экране. Возможно ли это?