v-download

Vue.js directive to download (and optionally transform) data
4,466 2
Install
npm install v-download
Latest Version:1.2.1
Vue:2
License:MIT
Last Updated:Jan 3, 2023
Links: GitHub  ·  npm
Maintainer: mikemenaker

v-download

Vue.js directive to download (and optionally transform) data

Install

For browser usage, import the component by adding a src tag in the header (): <script src="https://unpkg.com/v-download@1.2.0/dist/main.js">

For Node usage, install the v-download package using npm npm install --save v-download

Usage

First register the directive globally:

import DownloadData from 'v-download'

Vue.use(DownloadData)

Or locally:

import { downloadData } from 'v-download'

export default {
  directives: {
    downloadData
  }
}

Then use it in template:

<template>
  <button v-download-data="`some text`">Download!</button>
</template>

Data type

If type is provided it will be used as the mimetype:

<template>
  <button v-download-data="`{'example':'some text'}`" v-download-data:type="'json'">Download!</button>
</template>

If an object or array (instead of a string) is provided and the type is 'csv', 'tsv' or 'json', the object/array will be converted (json will be convert using JSON.stringify, csv/tsv is assuming an array and will be iterated)

<template>
  <button v-download-data="myObject" v-download-data:type="'json'">Download!</button>
</template>

File name

If filename is provided it will be used as the downloaded file name:

<template>
  <button v-download-data="`{'example':'some text'}`" v-download-data:filename="'mydownload.json'">Download!</button>
</template>

Related Packages

@vesperjs/vue

This is Vesper for Vue.js.

8,552 1
@teamwork/vue-dropdown-directive

A vue.js directive for handling dropdowns

4,628 9
@wzpo/md-ui

Another Momentum UI framework for Vue.js applications

2,054
vuenilla

Unstyled Vue.js component library.

1,552 2
vue-auth-href

Vue 3 directive and composable for downloading protected resources with authenti...

3,133 18

Version History

Version Released Vue License
1.2.1 ^2.6.8 MIT
1.2.0 ^2.6.8 MIT
1.1.0 MIT
1.0.4 MIT
1.0.3 MIT