| let methods = { | 
|   add() { | 
|     this.$Message.success('点击了添加按钮') | 
|   }, | 
|   edit() { | 
|     let rows = this.getSelected() | 
|     if (rows.length == 0) { | 
|       return this.$Message.error('请选择要编辑的行!') | 
|     } | 
|     this.$Message.success('点击了编辑按钮') | 
|   }, | 
|   del() { | 
|     let rows = this.getSelected() | 
|     if (rows.length == 0) { | 
|       return this.$Message.error('请选择要删除的行!') | 
|     } | 
|     this.$Message.success('点击了删除按钮') | 
|   }, | 
|   getSelected() { | 
|     return this.selectRows | 
|   }, | 
|   | 
|   selectionChange(selection) { | 
|     // console.log(selection); | 
|     // 选择行事件,只有单选才触发 | 
|     this.selectRows = selection | 
|     if (this.single) { | 
|       if (selection.length == 1) { | 
|         this.$emit('rowChange', selection[0]) | 
|       } | 
|       if (selection.length > 1) { | 
|         let _row = selection[selection.length - 1] | 
|         this.$refs.table.toggleRowSelection(selection[0]) | 
|         this.selectRows = [_row] | 
|       } | 
|     } | 
|     // 将selectionchange暴露出去 | 
|     this.$emit('selectionChange', selection) | 
|   } | 
| } | 
| export default { | 
|   methods | 
| } |