[Vuejs]-Vue 3 Composition API, setting date input using the valueAsDate property

3πŸ‘

βœ…

In vue it’s not recommended to manipulate the DOM using vanilla JS because Vue is data-driven framework which means that your input should be bound to a data property and it changes based on that data not by assigning raw data to its attributes like :

entryDateElem.value.valueAsDate = new Date() // you're manipulating directly the DOM ❌

the right way :

entryDate.value = new Date() // you're manipulating the data βœ”

Leave a comment