My actual code do the PDF download, its working fine. But instead of download i would like to open the PDF file in a new tab. Can anyone help?
'''
<div class="table__buttons display-if">
<template v-for="action in meta.actions">
<a
v-if="action === 'buttonDownload'"
:key="action"
:href="actions(action).to"
:target="actions(action).target"
:class="actions(action).class">
<btn-table
:tooltip="actions(action).tooltip"
:icon-name="actions(action).iconName"
type="button--table"
/>
</a>
...
methods: {
actions (action) {
const { item, routes } = this.meta
const actions = {
// Actions params
buttonDownload: {
to: `${item['link']}`,
target: '_blank',
iconName: 'icon-download',
tooltip: routes.buttonDownloadTooltip
},
尝试在内联中添加 target='_blank'
To view a PDF without downloading, try using window.open('url/for/pdf', '_blank')
. This can be achieved by using a Vue click event handler rather than the default <a>
tag behavior, like so:
<a
v-if="action === 'buttonDownload'"
:key="action"
:class="actions(action).class"
@click.prevent="window.open(actions(action).to, '_blank')"
>
...
</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.