Vue 2.0 Hello World
by shubhampokhriyal
HTML
<script src="https://unpkg.com/vue"></script>
<div id="app">
<div v-for="lists in xLists">
<my-comp v-for="(list, i) in lists" :key="i" :index="i"></my-comp>
</div>
</div>
JavaScript
Vue.component('my-comp', {
props: ['index'],
template: `
<div>
<input />
<button :data-index="index" @click="remove">del </button>
</div>
`,
methods: {
remove(e) {
var index = e.target.getAttribute('data-index')
this.$parent.xLists[1].splice(index, 1)
}
}
})
new Vue({
el: '#app',
data: {
xLists: {
1: [[], [], [], [], []]
}
}
})