4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Nuxt.js【Vue.js】で別タブ(別ページ)で開く方法

Last updated at Posted at 2021-07-07

Nuxt.js【Vue.js】で別タブ(別ページ)で開く方法になります。

target="_blank"を付与する

<template>
  <div>
    <!-- Nuxt -->
    <nuxt-link to="/demo" target="_blank">ボタン</nuxt-link> 

    <!-- Vue -->
    <router-link to="/demo" target="_blank">ボタン</router-link>
  </div>
</template>

target="_blank"を付与することで、別タブで開くことができます。

methodsなどで別タブ(別ページ)で開く方法

<template>
  <div>
    <button @click="open">ボタン</button>
  </div>
</template>

<script lang="ts">
import Vue from 'vue'

export default Vue.extend({
  methods: {
    open() {
      const url = '/demo'
      window.open(url, '_blank')
    }
  }
})
</script>

window.openを使用することで、methodsなどからも別タブで開くことができます。

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?