Vue.js <button> opening a new tab

Vue.js <button> opening a new tab

Matt Dean's photo
Matt Dean
·Jan 6, 2022·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

One thing I found difficult in remembering how to do was making a button in VueJS act as an <a> tag and open a link via a new tab. Fortunately, this was way easier than I thought!

<​button @​click​="​gotoLink()​">
  Click me! 
methods: {
​  gotoLink​() {
​    window​.​open​(​''​, ​'​_blank​'​);
Share this