I need to modify and update value in mongoDB. I use a form to do it. How to pre-fill an Input type text with value ?
CodePudding user response:
You can assign your value from mongoDB to the v-model you are using for input in mounted hook:
<script>
export default {
data() {
return {
message: ''
}
},
methods: {
async getDataFromMongoDB(){
// your existing code here...
return 'Value from DB'
}
},
async mounted() {
this.message = await this.getDataFromMongoDB()
},
}
</script>
<template>
<input v-model="message" />
</template>