Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to pre-fill an Input type text with value in vue.js

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 ?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading