<template>
<div class="container">
<div v-for="(item, index) in arr1" :key="index" >
<el-button type="primary" @click="addArr"><span>添加</span></el-button>
<el-button type="primary" @click="adddata"><span>添加数据</span></el-button>
<el-table border :data="item.arr2" style="width: 400px;">
<el-table-column label="input">
<template slot-scope="scope">
<el-input class="operate-input" v-model="scope.row.input" />
</template>
</el-table-column>
<el-table-column label="是否默认已选" width="182">
<template slot-scope="scope">
<el-radio-group v-model="scope.row.select">
<el-radio :label="0">否</el-radio>
<el-radio :label="1">是</el-radio>
</el-radio-group>
</template>
</el-table-column>
</el-table>
</div>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
arr1: [{arr2: []}]
}
},
watch: {
arr1: (e) => {
e.forEach(value => {
value.arr2.forEach(item => {
item.input = '2'
item.select = 1
})
})
}
},
methods: {
addArr () {
this.arr1.push({arr2: []})
},
adddata () {
let data = {
value: 1,
date: '2018-8-8'
}
this.arr1.forEach(item => {
item.arr2.push(data)
})
this.arr1 = Array.from(this.arr1)
}
}
}
</script>
<style scoped>
</style>
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.