From 79f412dfdaf3a00bafe0f44b259cce5650fc8138 Mon Sep 17 00:00:00 2001 From: xiyifenheart <543597191@qq.com> Date: Tue, 8 Sep 2020 09:15:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20tooltip=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/bin/build-entry.js | 2 +- examples/versions.json | 2 +- packages/tooltip/src/main.js | 75 ++++++++++++++++++++++------------- packages/tooltip/src/main.vue | 2 +- 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/build/bin/build-entry.js b/build/bin/build-entry.js index f333d560f..0164284ef 100644 --- a/build/bin/build-entry.js +++ b/build/bin/build-entry.js @@ -113,7 +113,7 @@ ComponentNames.forEach((name) => { 'divider', 'progress', 'form', - 'form-item' + 'form-item', 'message', 'pagination', 'notification', diff --git a/examples/versions.json b/examples/versions.json index ac4db7a43..be55060ff 100644 --- a/examples/versions.json +++ b/examples/versions.json @@ -1 +1 @@ -{"1.4.13":"1.4","2.0.11":"2.0","2.1.0":"2.1","2.2.2":"2.2","2.3.9":"2.3","2.4.11":"2.4","2.5.4":"2.5","2.6.3":"2.6","2.7.2":"2.7","2.8.2":"2.8","2.9.2":"2.9","2.10.1":"2.10","2.11.1":"2.11","2.12.0":"2.12","0.0.4":"2.13"} \ No newline at end of file +{"1.4.13":"1.4","2.0.11":"2.0","2.1.0":"2.1","2.2.2":"2.2","2.3.9":"2.3","2.4.11":"2.4","2.5.4":"2.5","2.6.3":"2.6","2.7.2":"2.7","2.8.2":"2.8","2.9.2":"2.9","2.10.1":"2.10","2.11.1":"2.11","2.12.0":"2.12","0.0.5":"2.13"} \ No newline at end of file diff --git a/packages/tooltip/src/main.js b/packages/tooltip/src/main.js index 20978590b..2c8b00f21 100644 --- a/packages/tooltip/src/main.js +++ b/packages/tooltip/src/main.js @@ -3,7 +3,7 @@ import debounce from 'throttle-debounce/debounce' import { addClass, removeClass, on, off } from 'element-ui/src/utils/dom' import { generateId } from 'element-ui/src/utils/util' // eslint-disable-next-line -import { h, createApp} from 'vue' +import { h, createApp, Transition as _Transition } from 'vue' export default { name: 'ElTooltip', @@ -68,42 +68,60 @@ export default { if (this.$isServer) return this.popperVM = createApp({ - data: { node: '' }, - render(h) { + data() { + return { + node: '' + } + }, + render() { + debugger return this.node } }) + console.log(this.popperVM.node); + this.debounceClose = debounce(200, () => this.handleClosePopper()) }, - render(h) { + render() { + debugger if (this.popperVM) { - this.popperVM.node = ( - // -
{ - this.setExpectedState(false) - this.debounceClose() - }} - onMouseenter={() => { - this.setExpectedState(true) - }} - ref="popper" - role="tooltip" - id={this.tooltipId} - aria-hidden={this.disabled || !this.showPopper ? 'true' : 'false'} - v-show={!this.disabled && this.showPopper} - class={[ - 'el-tooltip__popper', - 'is-' + this.effect, - this.popperClass - ]} - > - {this.$slots.content || this.content} -
- //
+ this.popperVM.node = h(_Transition, { + name: this.transition, + onAfterLeave: this.doDestroy + }, + [ + h('div', + { + onMouseleave: () => { + this.setExpectedState(false) + this.debounceClose() + }, + onMouseenter: () => { + this.setExpectedState(true) + }, + ref: "popper", + role: "tooltip", + id: this.tooltipId, + 'aria-hidden': this.disabled || !this.showPopper ? 'true' : 'false', + directives: [ + { + name: 'show', + value: !this.disabled && this.showPopper + } + ], + class: [ + 'el-tooltip__popper', + 'is-' + this.effect, + this.popperClass + ] + }, + (this.$slots.content || this.content) + ) + ] ) + // this.popperVM.mount('body'); } const firstElement = this.getFirstElement() @@ -225,6 +243,7 @@ export default { if (!Array.isArray(slots)) return null let element = null for (let index = 0; index < slots.length; index++) { + console.log(slots[index], 'slots[index]'); // if (slots[index] && slots[index].tag) { element = slots[index] // } diff --git a/packages/tooltip/src/main.vue b/packages/tooltip/src/main.vue index b9c268381..e48a1c08c 100644 --- a/packages/tooltip/src/main.vue +++ b/packages/tooltip/src/main.vue @@ -14,7 +14,7 @@ popperClass ]" > - +