🐛(tree & carousel): 修复 tree 与 carousel 语法错误
更新文档
This commit is contained in:
parent
83d4622df9
commit
79acc7b078
@ -15,8 +15,7 @@ import {
|
|||||||
VNode,
|
VNode,
|
||||||
Ref,
|
Ref,
|
||||||
Component,
|
Component,
|
||||||
watch,
|
watch
|
||||||
onMounted,
|
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import CarouselItem from "../carouselItem/index.vue";
|
import CarouselItem from "../carouselItem/index.vue";
|
||||||
|
|
||||||
@ -75,7 +74,7 @@ const setItemInstanceBySlot = function (nodeList: VNode[]) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(slotsChange, function () {
|
watch(slotsChange, () => {
|
||||||
childrens.value = [];
|
childrens.value = [];
|
||||||
setItemInstanceBySlot((slot.default && slot.default()) as VNode[]);
|
setItemInstanceBySlot((slot.default && slot.default()) as VNode[]);
|
||||||
});
|
});
|
||||||
@ -83,14 +82,13 @@ watch(slotsChange, function () {
|
|||||||
provide("active", active);
|
provide("active", active);
|
||||||
provide("slotsChange", slotsChange);
|
provide("slotsChange", slotsChange);
|
||||||
|
|
||||||
// 上一页
|
|
||||||
const sub = function () {
|
const sub = function () {
|
||||||
for (var i = 0; i < childrens.value.length; i++) {
|
for (var i = 0; i < childrens.value.length; i++) {
|
||||||
if (childrens.value[i].props.id === active.value) {
|
if (childrens.value[i].props?.id === active.value) {
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
active.value = childrens.value[slots.length - 1].props.id;
|
active.value = childrens.value[slots.length - 1].props?.id;
|
||||||
} else {
|
} else {
|
||||||
active.value = childrens.value[i - 1].props.id;
|
active.value = childrens.value[i - 1].props?.id;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -100,11 +98,11 @@ const sub = function () {
|
|||||||
// 下一页
|
// 下一页
|
||||||
const add = function () {
|
const add = function () {
|
||||||
for (var i = 0; i < childrens.value.length; i++) {
|
for (var i = 0; i < childrens.value.length; i++) {
|
||||||
if (childrens.value[i].props.id === active.value) {
|
if (childrens.value[i].props?.id === active.value) {
|
||||||
if (i === childrens.value.length - 1) {
|
if (i === childrens.value.length - 1) {
|
||||||
active.value = childrens.value[0].props.id;
|
active.value = childrens.value[0].props?.id;
|
||||||
} else {
|
} else {
|
||||||
active.value = childrens.value[i + 1].props.id;
|
active.value = childrens.value[i + 1].props?.id;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -114,11 +112,11 @@ const add = function () {
|
|||||||
// 自动播放
|
// 自动播放
|
||||||
const autoplay = () => {
|
const autoplay = () => {
|
||||||
for (var i = 0; i < childrens.value.length; i++) {
|
for (var i = 0; i < childrens.value.length; i++) {
|
||||||
if (childrens.value[i].props.id === active.value) {
|
if (childrens.value[i].props?.id === active.value) {
|
||||||
if (i === childrens.value.length - 1) {
|
if (i === childrens.value.length - 1) {
|
||||||
active.value = childrens.value[0].props.id;
|
active.value = childrens.value[0].props?.id;
|
||||||
} else {
|
} else {
|
||||||
active.value = childrens.value[i + 1].props.id;
|
active.value = childrens.value[i + 1].props?.id;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -140,24 +138,21 @@ watch(
|
|||||||
:lay-anim="anim"
|
:lay-anim="anim"
|
||||||
:lay-indicator="indicator"
|
:lay-indicator="indicator"
|
||||||
:lay-arrow="arrow"
|
:lay-arrow="arrow"
|
||||||
:style="{ width: width, height: height }"
|
:style="{ 'width': width, 'height': height }"
|
||||||
>
|
>
|
||||||
<!-- 内容 -->
|
|
||||||
<div carousel-item>
|
<div carousel-item>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
<!-- 轮播 -->
|
|
||||||
<div class="layui-carousel-ind">
|
<div class="layui-carousel-ind">
|
||||||
<ul>
|
<ul>
|
||||||
<li
|
<li
|
||||||
v-for="ss in childrens"
|
v-for="(ss, index) in childrens"
|
||||||
:key="ss"
|
:key="index"
|
||||||
:class="[ss.props.id === active ? 'layui-this' : '']"
|
:class="[ss.props?.id === active ? 'layui-this' : '']"
|
||||||
@click.stop="change(ss.props.id)"
|
@click.stop="change(ss.props?.id)"
|
||||||
></li>
|
></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<!-- 操作 -->
|
|
||||||
<button class="layui-icon layui-carousel-arrow" lay-type="sub" @click="sub">
|
<button class="layui-icon layui-carousel-arrow" lay-type="sub" @click="sub">
|
||||||
{{ anim === "updown" ? "" : "" }}
|
{{ anim === "updown" ? "" : "" }}
|
||||||
</button>
|
</button>
|
||||||
|
@ -88,7 +88,7 @@ function handleClick(node: TreeData) {
|
|||||||
:only-icon-control="onlyIconControl"
|
:only-icon-control="onlyIconControl"
|
||||||
@node-click="handleClick"
|
@node-click="handleClick"
|
||||||
>
|
>
|
||||||
<template v-if="slots.title" v-slot:title="{ data }">
|
<template v-if="slots.title">
|
||||||
<slot name="title" :data="data"></slot>
|
<slot name="title" :data="data"></slot>
|
||||||
</template>
|
</template>
|
||||||
</tree-node>
|
</tree-node>
|
||||||
|
@ -38,7 +38,6 @@ export const useTree: UseTree = (props: TreeProps, emit: TreeEmits) => {
|
|||||||
(list) => {
|
(list) => {
|
||||||
const { checkedKeys, expandKeys } = tree.getKeys();
|
const { checkedKeys, expandKeys } = tree.getKeys();
|
||||||
emit("update:checkedKeys", checkedKeys);
|
emit("update:checkedKeys", checkedKeys);
|
||||||
// emit('update:expandKeys', expandKeys)
|
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user