我需要打开一个具有一定高度和宽度的新窗口。
在 vuejs2 中我有这样的东西:
Run Code Online (Sandbox Code Playgroud)<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>在 props.row.link 中有:http://host/charts/index.php?par=sth 所以这个 href 在新选项卡中打开,但没有高度和宽度,也不在新窗口中打开。
在 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>
Run Code Online (Sandbox Code Playgroud)
如何在 vue js 2 中实现这一点,也许作为点击方法?
小智 5
代替
<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>
这将防止链接被点击和重定向。此外,它还调用在组件的方法对象中声明的函数“openWindow”:
openWindow: function (link) {
window.open(...);
}
Run Code Online (Sandbox Code Playgroud)