diff --git a/examples/routers/table.vue b/examples/routers/table.vue
index 3634ed26..187a68b4 100644
--- a/examples/routers/table.vue
+++ b/examples/routers/table.vue
@@ -5,6 +5,7 @@
{
const data = [
diff --git a/src/components/table/table-body.vue b/src/components/table/table-body.vue
index c359cce3..22b55671 100644
--- a/src/components/table/table-body.vue
+++ b/src/components/table/table-body.vue
@@ -114,6 +114,11 @@
event.stopPropagation();
this.$parent.dblclickCurrentRow(_index, rowKey);
},
+ contextmenuCurrentRow (_index, event, rowKey) {
+ event.stopPropagation();
+ if (this.$parent.contentMenu) event.preventDefault();
+ this.$parent.contextmenuCurrentRow(_index, rowKey);
+ },
getSpan (row, column, rowIndex, columnIndex) {
const fn = this.$parent.spanMethod;
if (typeof fn === 'function') {
@@ -269,7 +274,8 @@
mouseenter: (e) => this.handleMouseIn(row._index, e, row._rowKey),
mouseleave: (e) => this.handleMouseOut(row._index, e, row._rowKey),
click: (e) => this.clickCurrentRow(row._index, e, row._rowKey),
- dblclick: (e) => this.dblclickCurrentRow(row._index, e, row._rowKey)
+ dblclick: (e) => this.dblclickCurrentRow(row._index, e, row._rowKey),
+ contextmenu: (e) => this.contextmenuCurrentRow(row._index, e, row._rowKey)
}
}, $tds);
@@ -337,7 +343,8 @@
mouseenter: (e) => this.handleMouseIn(row._index, e),
mouseleave: (e) => this.handleMouseOut(row._index, e),
click: (e) => this.clickCurrentRow(row._index, e),
- dblclick: (e) => this.dblclickCurrentRow(row._index, e)
+ dblclick: (e) => this.dblclickCurrentRow(row._index, e),
+ contextmenu: (e) => this.contextmenuCurrentRow(row._index, e)
}
}, $tds);
$tableTrs.push($tableTr);
diff --git a/src/components/table/table.vue b/src/components/table/table.vue
index d7ed2bef..a80fa674 100644
--- a/src/components/table/table.vue
+++ b/src/components/table/table.vue
@@ -266,6 +266,11 @@
// 4.1.0
loadData: {
type: Function
+ },
+ // 4.1.0
+ contentMenu: {
+ type: Boolean,
+ default: false
}
},
data () {
@@ -694,6 +699,13 @@
this.$emit('on-row-dblclick', JSON.parse(JSON.stringify(this.cloneData[_index])), _index);
}
},
+ contextmenuCurrentRow (_index, rowKey) {
+ if (rowKey) {
+ this.$emit('on-contextmenu', JSON.parse(JSON.stringify(this.getBaseDataByRowKey(rowKey))));
+ } else {
+ this.$emit('on-contextmenu', JSON.parse(JSON.stringify(this.cloneData[_index])), _index);
+ }
+ },
getSelection () {
// 分别拿根数据和子数据的已选项
let selectionIndexes = [];