javascript - 在 vuejs2 模板中将 link 作为新的 window 打开
javascript - open link as new window in vuejs2 template
我需要打开一个新的window,具有一定的高度和宽度。
在 vuejs2 中我有这样的东西:
<el-table-column label="Link" width="80">
<template scope="props">
<a v-bind:href="''+props.row.link+''" target="chart"> Link to chart </a>
</template>
</el-table-column>
and in props.row.link have: http://host/charts/index.php?par=sth
So this href open in new tab but without height and width and not in new window.
在html就是这么简单:
<a href="http://host/charts/index.php?par=1" onclick="window.open('http://host/charts/index.php?par=1', 'chart', 'width=1225, height=770'); return false;">Link to chart</a>
如何在 vue js 2 中实现,
也许作为点击方法?
不要使用 v-bind:href,而是调用一个函数来打开新的 window
而不是
<a v-bind:href="''+props.row.link+''" target="chart"> Link to chart </a>
使用
<a href="" v-on:click.stop.prevent="openWindow(props.row.link)">Link to chart</a>
这将阻止 link 被点击和重定向。
此外,它调用在组件的方法对象中声明的函数 "openWindow":
openWindow: function (link) {
window.open(...);
}
我需要打开一个新的window,具有一定的高度和宽度。
在 vuejs2 中我有这样的东西:
<el-table-column label="Link" width="80"> <template scope="props"> <a v-bind:href="''+props.row.link+''" target="chart"> Link to chart </a> </template> </el-table-column>
and in props.row.link have: http://host/charts/index.php?par=sth So this href open in new tab but without height and width and not in new window.
在html就是这么简单:
<a href="http://host/charts/index.php?par=1" onclick="window.open('http://host/charts/index.php?par=1', 'chart', 'width=1225, height=770'); return false;">Link to chart</a>
如何在 vue js 2 中实现, 也许作为点击方法?
不要使用 v-bind:href,而是调用一个函数来打开新的 window
而不是
<a v-bind:href="''+props.row.link+''" target="chart"> Link to chart </a>
使用
<a href="" v-on:click.stop.prevent="openWindow(props.row.link)">Link to chart</a>
这将阻止 link 被点击和重定向。 此外,它调用在组件的方法对象中声明的函数 "openWindow":
openWindow: function (link) {
window.open(...);
}