0
0

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 1 year has passed since last update.

[Vuetify]Veutifyでv-imgタグをクリックしたときに内部リンクに遷移させる

Posted at

はじめに

Veutifyのv-imgコンポーネントをクリックしたときに内部リンクに遷移させたい場面があったので、実装方法をご紹介します。

公式ドキュメントを参考に進めていきます。

環境

  • Vuetify:2.6.1

1. 実装方法

v-imgコンポーネントは、propstoを指定することができないため、

        <v-img
          to="/"
          :src="require('@/assets/logo.png')"
        >
        </v-img>

のように記述しても、遷移しません。

また、v-imgコンポーネントはclickイベントを設定できないため、メソッド内で遷移させることもできません。

        <v-img
          @click="goHome"
          :src="require('@/assets/logo.png')"
        >
        </v-img>

今回は、router-linkで囲うことで遷移させることができました。

       <router-link to="/">
        <v-img
          :src="require('@/assets/logo.png')"
        >
        </v-img>
      </router-link>

以上で実装完了です。

公式ドキュメントを参考に、できないことを確認することも大事だなと思いました。

2. 参考文献

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?