✨(component): 优化 carouselItem 代码 ts 警告
This commit is contained in:
parent
617cb7f6d2
commit
3ff243b446
@ -5,28 +5,27 @@ export default {
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { inject, Ref, computed, ref } from "vue";
|
||||
import { inject, Ref, computed, ref, ComputedRef, WritableComputedRef } from "vue";
|
||||
|
||||
const props = defineProps<{
|
||||
id: string;
|
||||
}>();
|
||||
|
||||
const active = inject("active");
|
||||
const active = inject("active") as WritableComputedRef<string>;
|
||||
const slotsChange: Ref<boolean> = inject("slotsChange") as Ref<boolean>;
|
||||
slotsChange.value = !slotsChange.value;
|
||||
|
||||
const anim = inject("anim");
|
||||
const anim = inject("anim") as ComputedRef<string>;
|
||||
const item = ref();
|
||||
const getStyle = computed<any>(() => {
|
||||
if (item.value) {
|
||||
let allChild = item.value.parentNode.children;
|
||||
let allChildNum = allChild.length;
|
||||
|
||||
let activeIndex,
|
||||
currentIndex = 0;
|
||||
let activeIndex = 0;
|
||||
let currentIndex = 0;
|
||||
for (let index = 0; index < allChild.length; index++) {
|
||||
const element = allChild[index];
|
||||
// @ts-ignore
|
||||
if (element.getAttribute("data-id") === active.value) {
|
||||
activeIndex = index;
|
||||
}
|
||||
@ -34,13 +33,10 @@ const getStyle = computed<any>(() => {
|
||||
currentIndex = index;
|
||||
}
|
||||
}
|
||||
// @ts-ignore
|
||||
let prevIndex = activeIndex > 0 ? activeIndex - 1 : allChildNum - 1;
|
||||
// @ts-ignore
|
||||
let nextIndex = activeIndex + 1 < allChildNum ? activeIndex + 1 : 0;
|
||||
// @ts-ignore
|
||||
let animation = anim.value;
|
||||
//状态 上一个 当前 下一个
|
||||
|
||||
if (activeIndex === currentIndex) {
|
||||
if (animation === "updown") {
|
||||
return {
|
||||
|
@ -33,6 +33,7 @@ layui - vue(谐音:类 UI) 是 一 套 Vue 3.0 的 桌 面 端 组 件 库 ,
|
||||
::: title 如何贡献
|
||||
:::
|
||||
|
||||
<br>
|
||||
<lay-timeline>
|
||||
<lay-timeline-item simple>欢迎在<a href="https://github.com/layui/layui-vue/issues/new">提交问题</a>上向我们反馈。欢迎功能请求。如果您想贡献,请查看<a href="https://gitee.com/layui/layui-vue/blob/next/CONTRIBUTING.md">快速指南</a>!</lay-timeline-item>
|
||||
<lay-timeline-item simple>如果您有什么想聊的,请随时加入我们的<a href="https://gitter.im/layui-vue/community">交流群</a>!</lay-timeline-item>
|
||||
|
Loading…
Reference in New Issue
Block a user