Tooltip: fix disabled tooltip affecting other instances

pull/7225/head
Leopoldthecoder 2017-09-25 15:13:06 +08:00 committed by 杨奕
parent 1552f87592
commit f457cd7f57
4 changed files with 33 additions and 14 deletions

View File

@ -91,6 +91,10 @@
line-height: 26px; line-height: 26px;
margin-top: 10px; margin-top: 10px;
} }
#code-sponsor-widget {
margin: 50px 0 0 -20px;
}
} }
.nav-dropdown-list { .nav-dropdown-list {
width: 120px; width: 120px;
@ -165,6 +169,7 @@
</template> </template>
</li> </li>
</ul> </ul>
<div id="code-sponsor-widget"></div>
</div> </div>
</template> </template>
<script> <script>

View File

@ -270,8 +270,8 @@
} }
}, },
handleClick() { handleClick(row) {
console.log('click'); console.log(row);
}, },
handleEdit(index, row) { handleEdit(index, row) {
@ -707,7 +707,7 @@
label="操作" label="操作"
width="100"> width="100">
<template scope="scope"> <template scope="scope">
<el-button @click="handleClick" type="text" size="small">查看</el-button> <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
<el-button type="text" size="small">编辑</el-button> <el-button type="text" size="small">编辑</el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -717,8 +717,8 @@
<script> <script>
export default { export default {
methods: { methods: {
handleClick() { handleClick(row) {
console.log(1); console.log(row);
} }
}, },

View File

@ -9,6 +9,7 @@
</head> </head>
<body> <body>
<div id="app"></div><% if (process.env.NODE_ENV === 'production') { %> <div id="app"></div><% if (process.env.NODE_ENV === 'production') { %>
<script src="https://app.codesponsor.io/scripts/qFcVkt4f3DQEg4zrwINGVg?theme=light&height=250&width=240"></script>
<script src="//cdn.jsdelivr.net/npm/vue@2.3.0/dist/vue.runtime.min.js"></script> <script src="//cdn.jsdelivr.net/npm/vue@2.3.0/dist/vue.runtime.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/vue-router@2.1.1/dist/vue-router.min.js"></script><% } %> <script src="//cdn.jsdelivr.net/npm/vue-router@2.1.1/dist/vue-router.min.js"></script><% } %>
</body> </body>

View File

@ -48,8 +48,7 @@ export default {
data() { data() {
return { return {
timeoutPending: null, timeoutPending: null
handlerAdded: false
}; };
}, },
@ -94,11 +93,10 @@ export default {
const nativeOn = vnode.data.nativeOn = vnode.data.nativeOn || {}; const nativeOn = vnode.data.nativeOn = vnode.data.nativeOn || {};
data.staticClass = this.concatClass(data.staticClass, 'el-tooltip'); data.staticClass = this.concatClass(data.staticClass, 'el-tooltip');
if (this.handlerAdded) return vnode; on.mouseenter = this.addEventHandle(on.mouseenter, this.show);
on.mouseenter = this.addEventHandle(on.mouseenter, () => { this.setExpectedState(true); this.handleShowPopper(); }); on.mouseleave = this.addEventHandle(on.mouseleave, this.hide);
on.mouseleave = this.addEventHandle(on.mouseleave, () => { this.setExpectedState(false); this.debounceClose(); }); nativeOn.mouseenter = this.addEventHandle(nativeOn.mouseenter, this.show);
nativeOn.mouseenter = this.addEventHandle(nativeOn.mouseenter, () => { this.setExpectedState(true); this.handleShowPopper(); }); nativeOn.mouseleave = this.addEventHandle(nativeOn.mouseleave, this.hide);
nativeOn.mouseleave = this.addEventHandle(nativeOn.mouseleave, () => { this.setExpectedState(false); this.debounceClose(); });
return vnode; return vnode;
}, },
@ -108,9 +106,24 @@ export default {
}, },
methods: { methods: {
show() {
this.setExpectedState(true);
this.handleShowPopper();
},
hide() {
this.setExpectedState(false);
this.debounceClose();
},
addEventHandle(old, fn) { addEventHandle(old, fn) {
this.handlerAdded = true; if (!old) {
return old ? Array.isArray(old) ? old.concat(fn) : [old, fn] : fn; return fn;
} else if (Array.isArray(old)) {
return old.indexOf(fn) > -1 ? old : old.concat(fn);
} else {
return old === fn ? old : [old, fn];
}
}, },
concatClass(a, b) { concatClass(a, b) {