3
2

More than 1 year has passed since last update.

【Vue3】フォーカス時にテキストが全選択される input

Last updated at Posted at 2022-10-25

focusdemo.gif

<script setup lang="ts">
import { ref } from 'vue';

const input = ref<HTMLInputElement>()
</script>

<template>
  <input 
    ref="input"
    @focus="input?.select()"
  />
</template>

ユーザーが1クリックでコピー / 削除 / 入力などの作業を行えるので便利です。

 
 

フロントエンドのことをよく呟いています
Follow @punksy2

3
2
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
3
2