mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-03 13:44:47 +08:00
fix: 对未解绑的公共事件,在页面销毁时解绑
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { list } from "./high/list";
|
||||
import { ref, nextTick } from "vue";
|
||||
import { emitter } from "@/utils/mitt";
|
||||
|
||||
defineOptions({
|
||||
name: "PureTableHigh"
|
||||
@@ -10,11 +9,6 @@ defineOptions({
|
||||
const selected = ref(0);
|
||||
|
||||
function tabClick({ index }) {
|
||||
if (index == 0) {
|
||||
nextTick(() => {
|
||||
emitter.emit("setAdaptive");
|
||||
});
|
||||
}
|
||||
selected.value = index;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { useColumns } from "./columns";
|
||||
import { emitter } from "@/utils/mitt";
|
||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||
|
||||
const tableRef = ref();
|
||||
|
||||
@@ -15,18 +14,6 @@ const {
|
||||
onSizeChange,
|
||||
onCurrentChange
|
||||
} = useColumns();
|
||||
|
||||
onMounted(() => {
|
||||
emitter.on("setAdaptive", () => {
|
||||
// 设置表格自适应高度(用于表格外的元素高度改变或者元素隐藏时主动对表格进行自适应高度调整)
|
||||
tableRef.value.setAdaptive();
|
||||
});
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
// 解绑`setAdaptive`公共事件,防止多次触发
|
||||
emitter.off("setAdaptive");
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user