[Vuejs]-Vue.js v-model input value and populate existing data

0👍

Your Template neet to be display so:

<div class="field" v-for="(m, index) in meta" :key="index">
<input :v-model="m" name="type" class="form-control shadow-btn" />
</div>

0👍

Try this approach!

new Vue({
    el:"#app",
    data: {
        meta:['Meta 1','Meta 2']
    },
    methods: {
        addInput(){
            alert("Do something!");
        }
    },
});
<!DOCTYPE html>
<html lang="en">
<head>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <div class="field" v-for="(m, index) in meta" :key="index">
            <input :value="m" name="type" class="form-control shadow-btn" />
        </div>
        <a href="javascript:void(0)" @click="addInput">add</a>
    </div>
</body>
</html>

Leave a comment