diff --git a/package/component/package.json b/package/component/package.json index 7aa6039b..e5ad67df 100644 --- a/package/component/package.json +++ b/package/component/package.json @@ -1,6 +1,6 @@ { "name": "@layui/layui-vue", - "version": "1.2.3", + "version": "1.2.5", "author": "就眠儀式", "license": "MIT", "description": "a component library for Vue 3 base on layui-vue", diff --git a/package/component/src/component/affix/index.vue b/package/component/src/component/affix/index.vue index cf1fdc4f..c7af5305 100644 --- a/package/component/src/component/affix/index.vue +++ b/package/component/src/component/affix/index.vue @@ -18,12 +18,12 @@ export interface LayAiffxProps { } const props = withDefaults(defineProps(), { offset: 0, - position: 'top', + position: "top", target: () => { return document.body; }, }); -const emit = defineEmits(['scroll']) +const emit = defineEmits(["scroll"]); const outWindow = ref(false); const dom = ref(); @@ -43,7 +43,7 @@ const getStyle = computed(() => { bottom: "unset", left: orginOffsetLeft - marginLeft + "px", }; - if (props.position === 'top') { + if (props.position === "top") { style.top = fixedOffset - marginTop + "px"; } else { style.bottom = fixedOffset - marginBottom + "px"; @@ -56,7 +56,7 @@ const checkInWindow = () => { if (dom.value) { let offsetTop = dom.value.offsetTop; let scrollTop = props.target?.scrollTop; - if (props.position === 'top') { + if (props.position === "top") { //top检查 当前元素与容器顶部距离-减去滚动条的高度+容器offsetTop let result = offsetTop - scrollTop + props.target.offsetTop; if (result < fixedOffset) { @@ -82,15 +82,15 @@ const checkInWindow = () => { } } else { if (result < fixedOffset) { - changeScrollTop = scrollTop - result + props.offset + changeScrollTop = scrollTop - result + props.offset; outWindow.value = true; } } } - emit('scroll', { + emit("scroll", { targetScroll: scrollTop, affixed: outWindow.value, - offset: !outWindow.value ? 0 : Math.abs(scrollTop - changeScrollTop) + offset: !outWindow.value ? 0 : Math.abs(scrollTop - changeScrollTop), }); } }; @@ -106,14 +106,14 @@ const getDomStyle = (dom: any, attr: string) => { onMounted(() => { nextTick(() => { - orginOffsetTop = dom.value.offsetTop - props.target.offsetTop - orginOffsetLeft = dom.value.getBoundingClientRect().left - marginLeft = parseFloat(getDomStyle(dom.value, 'marginLeft')) - marginTop = parseFloat(getDomStyle(dom.value, 'marginTop')) - marginBottom = parseFloat(getDomStyle(dom.value, 'marginBottom')) - fixedOffset = props.offset + props.target.offsetTop - if (props.position === 'bottom') { - fixedOffset = props.offset + orginOffsetTop = dom.value.offsetTop - props.target.offsetTop; + orginOffsetLeft = dom.value.getBoundingClientRect().left; + marginLeft = parseFloat(getDomStyle(dom.value, "marginLeft")); + marginTop = parseFloat(getDomStyle(dom.value, "marginTop")); + marginBottom = parseFloat(getDomStyle(dom.value, "marginBottom")); + fixedOffset = props.offset + props.target.offsetTop; + if (props.position === "bottom") { + fixedOffset = props.offset; } props.target.addEventListener("scroll", checkInWindow, true); checkInWindow(); diff --git a/package/component/src/component/cascader/index.vue b/package/component/src/component/cascader/index.vue index 3481b61c..890e01c7 100644 --- a/package/component/src/component/cascader/index.vue +++ b/package/component/src/component/cascader/index.vue @@ -174,7 +174,7 @@ function findData(orginData: any, level: number) { const dataContainer = ref([]); const selectBar = (item: any, selectIndex: number, parentIndex: number) => { treeData.value[parentIndex].selectIndex = selectIndex; - if (item.children) { + if (item.children && item.children.length > 0) { treeData.value[parentIndex + 1].selectIndex = null; treeData.value[parentIndex + 1].data = findData(item.children, 1); } diff --git a/package/component/src/component/colorPicker/index.vue b/package/component/src/component/colorPicker/index.vue index 19b6dbed..e4fb98d3 100644 --- a/package/component/src/component/colorPicker/index.vue +++ b/package/component/src/component/colorPicker/index.vue @@ -72,11 +72,9 @@ watch([red, green, blue], (newValue) => { rgba2hex(red.value, green.value, blue.value, alpha.value) ); let { h, s, v } = rgb2hsv(red.value, green.value, blue.value); - hue.value = h; saturation.value = s; value.value = v; pointStyle.value = `top: ${100 - v * 100}%;left: ${s * 100}%;`; - hueSliderStyle.value = `left: ${(hue.value / 360) * 100}%;`; }); watch(alpha, () => { diff --git a/package/component/src/component/datePicker/index.vue b/package/component/src/component/datePicker/index.vue index 861e4eee..75050771 100644 --- a/package/component/src/component/datePicker/index.vue +++ b/package/component/src/component/datePicker/index.vue @@ -1,10 +1,12 @@