handsomer223
handsomer223

Reputation: 955

Vuejs redirect to url when clicked on a button

I have a button on which when I click I want it to redirect to a url that is begin passed in it.

Here is my code.

<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>

When I click on the button it doesnot redirect me to a url.

I am thinking of making the tag look like button and use it redirect it but how to do it via button.

Upvotes: 4

Views: 16690

Answers (1)

Janis Jansen
Janis Jansen

Reputation: 1025

That maybe is because window isn't an object of this. Try using just window.location and it should work just fine.

Upvotes: 7

Related Questions