4

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.

handsomer223
  • 885
  • 4
  • 12
  • 16

1 Answers1

7

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

Janis Jansen
  • 996
  • 1
  • 16
  • 36