Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 268
handsomer223 Avatar asked Mar 07 '23 07:03

handsomer223


1 Answers

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

like image 195
Janis Jansen Avatar answered Mar 30 '23 14:03

Janis Jansen