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

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

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

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

这很方便,因为用户可以一键复制/删除/输入。

 
 

我经常嘀咕前端
关注@punksy2


原创声明:本文系作者授权爱码网发表,未经许可,不得转载;

原文地址:https://www.likecs.com/show-308631562.html

相关文章: