feat: 加强 carousel 组件
This commit is contained in:
parent
e3bb0309a3
commit
14d0f5fdaf
@ -35,7 +35,7 @@ const props = withDefaults(defineProps<LayButtonProps>(), {
|
|||||||
loading: false,
|
loading: false,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
nativeType: "button",
|
nativeType: "button",
|
||||||
borderStyle: "soild"
|
borderStyle: "soild",
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(["click"]);
|
const emit = defineEmits(["click"]);
|
||||||
@ -48,9 +48,9 @@ const onClick = (event: any) => {
|
|||||||
|
|
||||||
const styles = computed(() => {
|
const styles = computed(() => {
|
||||||
return {
|
return {
|
||||||
border: `1px ${props.borderStyle}`
|
border: `1px ${props.borderStyle}`,
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
||||||
const classes = computed(() => {
|
const classes = computed(() => {
|
||||||
return [
|
return [
|
||||||
|
@ -86,13 +86,10 @@ 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++) {
|
||||||
// @ts-ignore
|
|
||||||
if (childrens.value[i].props.id === active.value) {
|
if (childrens.value[i].props.id === active.value) {
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
// @ts-ignore
|
|
||||||
active.value = childrens.value[slots.length - 1].props.id;
|
active.value = childrens.value[slots.length - 1].props.id;
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
|
||||||
active.value = childrens.value[i - 1].props.id;
|
active.value = childrens.value[i - 1].props.id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -102,18 +99,36 @@ 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++) {
|
||||||
// @ts-ignore
|
|
||||||
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) {
|
||||||
// @ts-ignore
|
|
||||||
active.value = childrens.value[0].props.id;
|
active.value = childrens.value[0].props.id;
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
|
||||||
active.value = childrens.value[i + 1].props.id;
|
active.value = childrens.value[i + 1].props.id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 自动播放
|
||||||
|
const autoplay = () => {
|
||||||
|
for (var i = 0; i < childrens.value.length; i++) {
|
||||||
|
if (childrens.value[i].props.id === active.value) {
|
||||||
|
if (i === childrens.value.length - 1) {
|
||||||
|
active.value = childrens.value[0].props.id;
|
||||||
|
}
|
||||||
|
active.value = childrens.value[i + 1].props.id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.autoplay,
|
||||||
|
() => {
|
||||||
|
setInterval(autoplay, props.interval);
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -262,7 +262,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.scrollbar-y ::-webkit-scrollbar{
|
.scrollbar-y ::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
//移动端隐藏自定义滚动条
|
//移动端隐藏自定义滚动条
|
||||||
@ -270,10 +270,10 @@ export default defineComponent({
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
//移动端显示原生滑块
|
//移动端显示原生滑块
|
||||||
.hide.scrollbar-box .scrollbar-y ::-webkit-scrollbar{
|
.hide.scrollbar-box .scrollbar-y ::-webkit-scrollbar {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.hide.scrollbar-box .scrollbar-y .scroll-wrap{
|
.hide.scrollbar-box .scrollbar-y .scroll-wrap {
|
||||||
scrollbar-width: auto;
|
scrollbar-width: auto;
|
||||||
-ms-overflow-style: scrollbar;
|
-ms-overflow-style: scrollbar;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
::: demo
|
::: demo
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<lay-carousel v-model="active">
|
<lay-carousel v-model="active1">
|
||||||
<lay-carousel-item id="1">
|
<lay-carousel-item id="1">
|
||||||
<div style="color: white;text-align: center;width:100%;height:300px;line-height:300px;background-color:#79C48C;">条目一</div>
|
<div style="color: white;text-align: center;width:100%;height:300px;line-height:300px;background-color:#79C48C;">条目一</div>
|
||||||
</lay-carousel-item>
|
</lay-carousel-item>
|
||||||
@ -29,10 +29,10 @@ import { ref } from 'vue'
|
|||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
const active = ref("1")
|
const active1 = ref("1")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
active
|
active1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ export default {
|
|||||||
::: demo
|
::: demo
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<lay-carousel v-model="active" anim="updown">
|
<lay-carousel v-model="active2" anim="updown">
|
||||||
<lay-carousel-item id="1">
|
<lay-carousel-item id="1">
|
||||||
<div style="color: white;text-align: center;width:100%;height:300px;line-height:300px;background-color:#79C48C;">条目一</div>
|
<div style="color: white;text-align: center;width:100%;height:300px;line-height:300px;background-color:#79C48C;">条目一</div>
|
||||||
</lay-carousel-item>
|
</lay-carousel-item>
|
||||||
@ -68,10 +68,10 @@ import { ref } from 'vue'
|
|||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
const active = ref("1")
|
const active2 = ref("1")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
active
|
active2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ export default {
|
|||||||
::: demo
|
::: demo
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<lay-carousel v-model="active" indicator="outside">
|
<lay-carousel v-model="active3" indicator="outside">
|
||||||
<lay-carousel-item id="1">
|
<lay-carousel-item id="1">
|
||||||
<div style="color: white;text-align: center;width:100%;height:300px;line-height:300px;background-color:#79C48C;">条目一</div>
|
<div style="color: white;text-align: center;width:100%;height:300px;line-height:300px;background-color:#79C48C;">条目一</div>
|
||||||
</lay-carousel-item>
|
</lay-carousel-item>
|
||||||
@ -107,10 +107,10 @@ import { ref } from 'vue'
|
|||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
const active = ref("1")
|
const active3 = ref("1")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
active
|
active3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ export default {
|
|||||||
::: demo
|
::: demo
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<lay-carousel v-model="active">
|
<lay-carousel v-model="active4">
|
||||||
<lay-carousel-item :id="item.id" v-for="item in arrays">
|
<lay-carousel-item :id="item.id" v-for="item in arrays">
|
||||||
<div style="color: white;text-align: center;width:100%;height:300px;line-height:300px;background-color:#79C48C;">{{ item.text }}</div>
|
<div style="color: white;text-align: center;width:100%;height:300px;line-height:300px;background-color:#79C48C;">{{ item.text }}</div>
|
||||||
</lay-carousel-item>
|
</lay-carousel-item>
|
||||||
@ -137,7 +137,7 @@ import { ref } from 'vue'
|
|||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
const active = ref("1")
|
const active4 = ref("1")
|
||||||
|
|
||||||
const arrays = ref([
|
const arrays = ref([
|
||||||
{id: "1", text: ""},
|
{id: "1", text: ""},
|
||||||
@ -147,7 +147,7 @@ export default {
|
|||||||
])
|
])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
active,
|
active4,
|
||||||
arrays
|
arrays
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
<li>
|
<li>
|
||||||
<h3>1.0.2 <span class="layui-badge-rim">2022-04-07</span></h3>
|
<h3>1.0.2 <span class="layui-badge-rim">2022-04-07</span></h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>[新增] button 组件 border-style 属性, 允许自定义边框样式。(by @就眠儀式)</li>
|
<li>[新增] button 组件 border-style 属性, 自定义边框样式。(by @就眠儀式)</li>
|
||||||
<li>[新增] config-provider 组件 dark-partial 属性, 夜间主题偏好配置。(by @就眠儀式)</li>
|
<li>[新增] config-provider 组件 dark-partial 属性, 夜间主题偏好配置。(by @就眠儀式)</li>
|
||||||
|
<li>[新增] carousel 组件 autoplay 属性, 开启自动轮播, 默认为 true。(by @就眠儀式)</li>
|
||||||
|
<li>[新增] carousel 组件 interval 属性, 用于控制轮播间隔。(by @就眠儀式)</li>
|
||||||
<li>[修复] page 组件 pages 属性为单数时, 页码计算错误。(by @就眠儀式)</li>
|
<li>[修复] page 组件 pages 属性为单数时, 页码计算错误。(by @就眠儀式)</li>
|
||||||
<li>[修复] panel 组件 background-color 为透明的问题。(by @就眠儀式)</li>
|
<li>[修复] panel 组件 background-color 为透明的问题。(by @就眠儀式)</li>
|
||||||
<li>[修复] tab 组件 layui-tab-head 默认存在背景色。(by @就眠儀式)</li>
|
<li>[修复] tab 组件 layui-tab-head 默认存在背景色。(by @就眠儀式)</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user