What Vue method do you recommend for changing an input element's type on focus?
e.g. onfocus="this.type = 'date'"
I am specifically looking to switch the input type from text to date in order to utilize the placeholder property.
My Solution:
<template>
<input
type="text"
placeholder="Birthday"
value="foo"
@focus="setType('date')"
@blur="setType('text')"
/>
</template>
<script>
...
export default defineComponent({
setup(){
const el = ref<HTMLInputElement>()
const setType = (x: string) => el.type = x
return {el, setType}
}
})
</script>
Error Message:
Property 'type' does not exist on type 'Ref<HTMLInputElement | undefined>'