open url in new window vue

To open a URL in a new window using Vue, you can follow these steps:

  1. First, import the router instance from your Vue router package. This will allow you to programmatically navigate to a new URL.
import router from 'vue-router';
  1. In your Vue component, add a method that will handle the navigation to the new URL. This method will use the router instance to navigate to the desired URL.
methods: {
  openUrlInNewWindow(url) {
    window.open(url, '_blank');
  },
},
  1. In your template, add a button or a link element that triggers the openUrlInNewWindow method when clicked. Pass the desired URL as a parameter to the method.
<button @click="openUrlInNewWindow('https://example.com')">Open URL in new window</button>

That's it! When the button or link is clicked, the openUrlInNewWindow method will be called, and the specified URL will be opened in a new window.