Open guowei opened 5 years ago
例如:
<tree-table expand-key="sex" :expand-type="false" :selectable="false" :columns="columns" :data="data" > <template slot="likes" slot-scope="scope"> <Button @click="handle(scope)">123</Button> </template> </tree-table> data: [ { name: 'Jack', sex: 'male', likes: ['football', 'basketball'], score: 10 } ] methods: { handle (scope) { const aa = scope; const newChild = { name: '子节点', sex: 'male', likes: ['football', 'basketball'], score: 20, children: [], }; if (!aa.row.children) { console.log('>>>>>'); this.$set(aa.row, 'children', []); aa.row.children.push(newChild); // 表格无法渲染,新加的 childeren } else { aa.row.children.push(newChild); } } }
你在scope里面加当然没用,要在源数据data里面加才行
例如: