You can handle the @keydown event to detect if the first entered symbol is a space and prevent entering if so. Here is an example:
<script setup>
import { ref } from "vue";
const msg = ref("");
function onInput(e) {
msg.value = e.target.value;
}
function preventLeadingSpace(e) {
if (msg.value.length === 0 && e.key === " ") {
e.preventDefault();
}
}
</script>
<template>
<input :value="msg" @input="onInput" @keydown="preventLeadingSpace" />
</template>