[临时修复]解决tooltip数据不更新的问题
This commit is contained in:
parent
5c11b731d5
commit
9d829729f4
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<transition v-show="visible">
|
||||
<transition v-if="visible">
|
||||
<div :class="['layui-popper', {'layui-dark' : isDark}]" :style="style" :position="innnerPosition">
|
||||
<slot>{{content}}</slot>
|
||||
<div class="layui-popper-arrow"></div>
|
||||
@ -16,7 +16,7 @@
|
||||
<script setup lang="ts">
|
||||
import "./index.less";
|
||||
import postionFns from "./calcPosition";
|
||||
import { getCurrentInstance, CSSProperties, ref, watch, onUpdated, defineEmits, onMounted} from "vue";
|
||||
import { getCurrentInstance, CSSProperties, ref, watch, onUpdated, defineEmits, onMounted, des} from "vue";
|
||||
import {on} from "../../tools/domUtil";
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@ -65,12 +65,13 @@
|
||||
const doHidden = function(e : MouseEvent){
|
||||
if ((checkTarget.value && props.el.contains(e.target)) || (props.enterable && popper.value.contains(e.target))) return;
|
||||
style.value = {top: (-window.innerHeight) + 'px',left:0};
|
||||
visible.value = false;
|
||||
popper.value.remove();
|
||||
// visible.value = false;
|
||||
innnerPosition.value = props.position;
|
||||
}
|
||||
|
||||
// 事件绑定
|
||||
on(props.el, triggerArr[0], doShow);
|
||||
// on(props.el, triggerArr[0], doShow);
|
||||
on(triggerArr[1]??props.el, triggerArr[2], doHidden);
|
||||
checkTarget.value = triggerArr[3];
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import usePopper from "../popper/usePopper";
|
||||
import { defineComponent} from "vue";
|
||||
import { on } from "../../tools/domUtil";
|
||||
import { defineComponent, h, render} from "vue";
|
||||
import popper from "../popper/index.vue";
|
||||
export default defineComponent({
|
||||
name: "LayTooltip",
|
||||
props: {
|
||||
@ -23,7 +25,11 @@ export default defineComponent({
|
||||
mounted() {
|
||||
const _this = this;
|
||||
this.$nextTick(() => {
|
||||
usePopper.createPopper(_this.$el, _this.$props, "hover");
|
||||
on(_this.$el, 'mouseenter', () => {
|
||||
const container: HTMLDivElement = document.createElement("div");
|
||||
render(h(popper, {...this.$props, el: this.$el}), container);
|
||||
container.firstElementChild && document.body.appendChild(container.firstElementChild);
|
||||
})
|
||||
});
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user