Yoshie Muranaka | b1a7191 | 2020-04-29 10:52:39 -0700 | [diff] [blame^] | 1 | <template> |
| 2 | <b-link |
| 3 | class="btn btn-primary d-block align-self-center" |
| 4 | :download="download" |
| 5 | :href="href" |
| 6 | > |
| 7 | {{ $t('global.action.export') }} |
| 8 | </b-link> |
| 9 | </template> |
| 10 | |
| 11 | <script> |
| 12 | export default { |
| 13 | props: { |
| 14 | data: { |
| 15 | type: Array, |
| 16 | default: () => [] |
| 17 | }, |
| 18 | fileName: { |
| 19 | type: String, |
| 20 | default: 'data' |
| 21 | } |
| 22 | }, |
| 23 | computed: { |
| 24 | dataForExport() { |
| 25 | return JSON.stringify(this.data); |
| 26 | }, |
| 27 | download() { |
| 28 | return `${this.fileName}.json`; |
| 29 | }, |
| 30 | href() { |
| 31 | return `data:text/json;charset=utf-8,${this.dataForExport}`; |
| 32 | } |
| 33 | } |
| 34 | }; |
| 35 | </script> |