uniapp ,vue,js日历卡片可滑动日期可点击选择可更改颜色样式

效果图

日期可左右滑动无限制,当天日期纯绿色填充标识样式,点击其他日期绿色边框标识(日期颜色可在样式里面更改$am-color)

1.创建一个.vue文件

<template>
	<view :class="[fold&&'flex flex-items-center', 'wx-card mt20']">
		<view :class="[!fold&&'f32 flex flex-center pb20',fold&&'card-header']" @click="initDate">
			<view :class="[fold&&'f26 tc']">{
  
  {nowDay.year}}年</view>
			<view :class="[fold&&'flex flex-center flex-items-end']">
				<text :class="[fold&&'f70']">{
  
  {nowDay.month}}</text>
				<text :class="[fold&&'f30','pb10 ml5']">月</text>
			</view>
		</view>
		<view v-if="verticaled" class="flex flex-items-center flex-around pb10">
			<view :class="['tc w7']" v-for="item in weeks" :key="item">
				{
  
  {item}}
			</view>
		</view>
		<view class="flex-1 fit-height">
			<swiper 
			:current="tabIndex" 
			:animation="animationData" 
			:class="[fold?'swiper-week':'swiper-month','flex-1']" 
			:vertical="verticaled"
			:duration="duration" 
			@change="ontabchange" 
			@animationfinish="animationfinish" >
				<swiper-item v-for="(days,index1) in list" :key="index1">
					<template v-if="fold">
						<view class="month-wrap flex flex-items-center flex-around pt5">
							<view :class="['tc',!(item.isNow||item.isFuture)&&'graya']" v-for="item in days.weeks" :key="item.day" @click="clickTime(item)">
								<view>{
  
  {item.week}}</view>
								<view :class="[item.isNow&&'active',item.isActive&&'active','mt20 pb20',!item.isAct&&item.isAM&&'isAM',!item.isAct&&item.isPM&&'isPM',item.isAct&&'isAct']">
									<text :class="[item.isNow&&'isNowWap',item.isActive&&'isSelect']">{
  
  {item.day}}</text>
								</view>
							</view>
						</view>
					</template>
					<template v-else>
						<view class="month-wrap">
							<view v-if="!verticaled" class="flex flex-items-center flex-around">
								<view :class="['tc w7']" v-for="item in weeks" :key="item">
									{
  
  {item}}
								</view>
							</view>
							<view class="flex flex-items-center flex-wrap">
								<view :class="['tc w7',(!(item.isNow||item.isFuture)&&!verticaled||(!item.isMonth))&&'graya',item.isNow&&'active',item.isActive&&'active',!item.isAct&&item.isAM&&'isAM',!item.isAct&&item.isPM&&'isPM',item.isAct&&'isAct']" v-for="(item,index) in days.months" :key="index" @click="clickTime(item)">
### 实现卡片衔接滑动效果 在 UniApp Vue实现卡片衔接滑动效果主要依赖于 `swiper` 组件。此组件允许创建具有平滑过渡动画的轮播图或卡片切换效果[^1]。 对于卡片衔接滑动的效果,可以利用 `swiper` 的特性来构建。下面是一个具体的例子: #### HTML 结构 ```html <template> <view class="container"> <!-- Swiper 容器 --> <swiper :indicator-dots="true" :autoplay="false" circular interval="5000" duration="500"> <!-- 每个 swiper-item 对应一张卡片 --> <swiper-item v-for="(item, index) in cardList" :key="index"> <view class="card"> {{ item.title }} </view> </swiper-item> </swiper> </view> </template> ``` #### JavaScript 部分 ```javascript <script> export default { data() { return { cardList: [ { title: "Card One", content: "Content of Card One" }, { title: "Card Two", content: "Content of Card Two" }, { title: "Card Three", content: "Content of Card Three" } ] }; } }; </script> ``` #### CSS 样式 ```css <style scoped> .container { width: 100%; } .card { display: flex; justify-content: center; align-items: center; height: 200px; background-color: #f8f8f8; } </style> ``` 上述代码展示了如何使用 `swiper` 和 `swiper-item` 来创建一组可以在水平方向上无缝连接并翻转显示的内容卡牌。这里设置了循环播放 (`circular`) 属性使得最后一张卡片之后会自动回到第一张;同时也启用了指示点(`indicator-dots`)以便用户知道当前处于哪一帧。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值