单击按钮时,Vuejs 重定向到 url

han*_*223 3 html vue.js vuejs2

我有一个按钮,当我点击时,我希望它重定向到一个开始传递的 url。

这是我的代码。

<template>
<button type="button" v-on:click="gotosite(modalDetails.final.product_url)">Buy</button>
</template>

<script>
 .
 ..
 ...
 .....
 methods : {
        gotosite(producturl){
        this.window.location.href = producturl
            }

</script>
<style></style>
Run Code Online (Sandbox Code Playgroud)

当我点击按钮时,它不会将我重定向到一个 url。

我正在考虑使标签看起来像按钮并使用它重定向它,但如何通过按钮来做到这一点。

Jan*_*sen 7

那可能是因为 window 不是this. 尝试使用 just window.location,它应该可以正常工作。