【问题标题】:Vuejs redirect to url when clicked on a button单击按钮时Vuejs重定向到url
【发布时间】:2018-10-14 14:29:39
【问题描述】:

我有一个按钮,当我单击该按钮时,我希望它重定向到开始传递的 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>

当我点击按钮时,它不会将我重定向到网址。

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

【问题讨论】:

    标签: html vue.js vuejs2


    【解决方案1】:

    这可能是因为 window 不是 this 的对象。尝试只使用window.location,它应该可以正常工作。

    【讨论】:

    • 成功了。但是如何让它在不同的选项卡中打开呢?现在它正在同一个标​​签中打开。
    • @handsomer223 that can be found here
    • @handsomer223 不要忘记选择有效的答案^^,干杯!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-23
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多