🐛(component): 修复文档缺陷

This commit is contained in:
就眠儀式
2022-09-15 02:12:11 +08:00
parent 72fab7c9a5
commit 9e52d2401a
4 changed files with 257 additions and 33 deletions

View File

@@ -35,7 +35,7 @@ const props = withDefaults(defineProps<LayTransferProps>(), {
height: "360px",
});
const emits = defineEmits(['update:modelValue','change'])
const emits = defineEmits(["update:modelValue", "change"]);
const leftDataSource: Ref<any[]> = ref([...props.dataSource]);
const rightDataSource: Ref<any[]> = ref([]);
@@ -62,28 +62,30 @@ const allLeftChange = (isChecked: boolean) => {
}
};
watch(() => props.modelValue, () => {
watch(
() => props.modelValue,
() => {
let targetDataSource: any[] = [];
let targetDataSource: any[] = [];
props.dataSource.forEach((ds) => {
if (props.modelValue.includes(ds[props.id])) {
targetDataSource.push(ds);
}
});
props.dataSource.forEach(ds => {
if(props.modelValue.includes(ds[props.id])) {
targetDataSource.push(ds);
}
})
leftDataSource.value = props.dataSource.filter(
(item) => !props.modelValue.includes(item[props.id])
);
leftDataSource.value = props.dataSource.filter(
(item) => !props.modelValue.includes(item[props.id])
);
_leftDataSource.value = props.dataSource.filter(
(item) => !props.modelValue.includes(item[props.id])
);
_leftDataSource.value = props.dataSource.filter(
(item) => !props.modelValue.includes(item[props.id])
);
rightDataSource.value = [...targetDataSource];
_rightDataSource.value = [...targetDataSource];
}, {immediate: true})
rightDataSource.value = [...targetDataSource];
_rightDataSource.value = [...targetDataSource];
},
{ immediate: true }
);
watch(
leftSelectedKeys,
@@ -143,7 +145,6 @@ watch(
);
const add = () => {
if (leftSelectedKeys.value.length === 0) {
return;
}
@@ -158,10 +159,10 @@ const add = () => {
rightDataSource.value.forEach((item) => {
targetKeys.push(item[props.id]);
})
});
emits("change", targetKeys)
emits("update:modelValue", targetKeys)
emits("change", targetKeys);
emits("update:modelValue", targetKeys);
leftSelectedKeys.value = [];
};
@@ -179,8 +180,8 @@ const remove = () => {
}
});
emits("change", targetKeys)
emits("update:modelValue", targetKeys)
emits("change", targetKeys);
emits("update:modelValue", targetKeys);
rightSelectedKeys.value = [];
};

View File

@@ -165,11 +165,11 @@ npm install @layui/icons-vue
function getIconUnicode(iconClass){
const iconEl = document.querySelector(`.site-doc-icon > li > .${iconClass}`);
const iconBeforeContent = getComputedStyle(iconEl,":before").content;
const iconBeforeContent = window?.getComputedStyle(iconEl,":before").content;
return iconBeforeContent;
}
onMounted(() => {
LayIconList.forEach((icon) => {
LayIconList?.forEach((icon) => {
const unicode = getIconUnicode(icon.class).charCodeAt(1).toString(16); // unicode 10进制转16进制
iconsUnicode.push(unicode)
});

View File

@@ -16,6 +16,8 @@
<li>
<h3>1.4.13 <span class="layui-badge-rim">2022-09-14</span></h3>
<ul>
<li>[新增] transfer 组件 modelValue (v-model) 属性。</li>
<li>[新增] transfer 组件 change 事件, 在左右转移数据时回调。</li>
<li>[修复] rate 组件 modelValue 值缺少响应式的问题。</li>
<li>[修复] transfer 组件 showSearch 为 true 时, 无法搜索的问题。</li>
</ul>