fix table重新渲染会修改props
This commit is contained in:
@@ -1058,7 +1058,7 @@ const _sfc_main = defineComponent({
|
||||
});
|
||||
};
|
||||
findFinalNode(0, tableColumns.value);
|
||||
const tableSelectedKeys = ref([...props.selectedKeys]);
|
||||
const tableSelectedKeys = ref(props.selectedKeys);
|
||||
const tableExpandKeys = ref([...props.expandKeys]);
|
||||
watch(() => props.selectedKeys, () => {
|
||||
tableSelectedKeys.value = props.selectedKeys;
|
||||
@@ -1102,7 +1102,10 @@ const _sfc_main = defineComponent({
|
||||
} else {
|
||||
hasChecked.value = false;
|
||||
}
|
||||
emit("update:selectedKeys", tableSelectedKeys.value);
|
||||
if (tableSelectedKeys.value != props.selectedKeys) {
|
||||
console.log("\u521D\u59CB\u5316\u8D4B\u503C\u89E6\u53D1\u4FEE\u6539", tableSelectedKeys.value, props.selectedKeys);
|
||||
emit("update:selectedKeys", tableSelectedKeys.value);
|
||||
}
|
||||
}, { deep: true, immediate: true });
|
||||
watch(tableExpandKeys, () => {
|
||||
emit("update:expandKeys", tableExpandKeys.value);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { w as withInstall } from "../badge/index2.js";
|
||||
import { defineComponent, useSlots, computed, resolveComponent, openBlock, createElementBlock, Fragment, renderList, normalizeClass, createElementVNode, createVNode, unref, withModifiers, createBlock, createCommentVNode, renderSlot, createTextVNode, toDisplayString, withCtx, createSlots, ref, watch, onMounted, nextTick } from "vue";
|
||||
import { defineComponent, useSlots, computed, resolveComponent, openBlock, createElementBlock, Fragment, renderList, normalizeClass, createElementVNode, createVNode, unref, withModifiers, createBlock, createCommentVNode, renderSlot, createTextVNode, toDisplayString, withCtx, createSlots, ref, watch, nextTick, onMounted } from "vue";
|
||||
import { _ as _sfc_main$2E, a as _sfc_main$2 } from "../checkbox/index2.js";
|
||||
import { _ as _sfc_main$3 } from "../transition/index2.js";
|
||||
const _hoisted_1 = ["onClick"];
|
||||
@@ -65,6 +65,9 @@ const _sfc_main$1 = defineComponent({
|
||||
if (!node.isDisabled) {
|
||||
emit("node-click", node);
|
||||
}
|
||||
if (props.showCheckbox) {
|
||||
node.isChecked = !node.isChecked;
|
||||
}
|
||||
}
|
||||
function handleRowClick(node) {
|
||||
if (!props.showLine) {
|
||||
@@ -146,7 +149,7 @@ const _sfc_main$1 = defineComponent({
|
||||
class: normalizeClass({
|
||||
"layui-tree-txt": true,
|
||||
"layui-disabled": node.isDisabled,
|
||||
"layui-this": __props.selectedKey === node.id
|
||||
"layui-this": __props.selectedKey === node.id || node.isChecked
|
||||
}),
|
||||
onClick: withModifiers(($event) => handleTitleClick(node), ["stop"])
|
||||
}, [
|
||||
@@ -418,18 +421,21 @@ const _sfc_main = defineComponent({
|
||||
loadNodeList();
|
||||
}, { deep: true, immediate: true });
|
||||
watch(() => props.checkedKeys, () => {
|
||||
console.log(tree.value);
|
||||
if (!unWatch.value) {
|
||||
loadNodeList();
|
||||
}
|
||||
}, {
|
||||
deep: true
|
||||
});
|
||||
watch(tree, () => {
|
||||
if (initStatus.value) {
|
||||
const { checkedKeys } = tree.value.getKeys();
|
||||
unWatch.value = true;
|
||||
emit("update:checkedKeys", checkedKeys);
|
||||
setTimeout(() => {
|
||||
nextTick(() => {
|
||||
unWatch.value = false;
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
}, { deep: true });
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user