Skip to content

305 - 大写 #1871

@Wants1203

Description

@Wants1203
// 你的答案
<script setup>
import { ref, vModelText } from 'vue';
const value = ref('');

vModelText.beforeUpdate = (el, binding) => {
  if (el.value && binding.modifiers.capitalize) {
    el.value = el.value.charAt(0).toUpperCase() + el.value.slice(1);
  }
};
</script>

<template>
  <input type="text" v-model.capitalize="value" />
</template>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Wants1203

        Issue actions

          305 - 大写 · Issue #1871 · webfansplz/vuejs-challenges