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.

1 Answer 1

7

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

Sign up to request clarification or add additional context in comments.

3 Comments

it worked. But how to make it open in a different tab? right now it is opening in the same tab.
@handsomer223 don't forget to pick the working answer ^^, Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.