Skip to content

Instantly share code, notes, and snippets.

@VisionYi
Last active December 31, 2020 14:53
Show Gist options
  • Save VisionYi/c341e21ca033f3bb38f8cef37db27b79 to your computer and use it in GitHub Desktop.
Save VisionYi/c341e21ca033f3bb38f8cef37db27b79 to your computer and use it in GitHub Desktop.
<template>
<div v-for="(item, index) in valueSync" :key="item.id">
name: <input type="text" v-model="item.name" @input="syncPropValue">
years: <input type="number" v-model="item.year" @input="syncPropValue">
<button @click="removePepole(index)">remove</button>
</div>
</template>
<script>
export default {
//...
medthods: {
removePepole(index) {
this.valueSync.splice(index, 1)
this.syncPropValue()
},
syncPropValue(value) {
this.$emit('input', this.valueSync)
},
},
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment