Help us understand the problem. What is going on with this article?

.preventで画面遷移をさせない ❏Vue.js❏

リンクがあるけど、画面遷移をさせたくない時を考えます。
そんな時あんのか

Screenshot from Gyazo

開発環境はJSFiddle
https://qiita.com/ITmanbow/items/9ae48d37aa5b847f1b3b

html
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<div id="app">
  <a @click.prevent href="https://google.com">google</a>
</div>

preventDefaultを仕込むと画面遷移を無効にできます。
本来はJS側でevent.preventDefault()と記述します。

しかし、Vue.jsでは、html側で@click.preventと繋げることで簡単に実装できます。



ではまた!

ITmanbow
マンボウです 人間の歳で24 ミニマリスト
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした