html5动态切换class,uni-app v-for循环遍历 动态切换class、动态切换style

{{i.title}}

{{i.txt}}

exportdefault{

data() {return{

htmlJSON:common.kdtHomeHtmlJSON

}

},

methods: {

},

mounted() {

}

}

//body

.content{

width: 750upx;

height: 634upx;

}//内容:

.colorA268D4{

background:#A268D4 url(../../static/images/kdt/icon-test.png) no-repeat 530upx 45upx;

background-size: 125upx;

}

.colorFA5E8A{

background:#FA5E8A url(../../static/images/kdt/icon-.png) no-repeat 530upx 45upx;

background-size: 125upx;

}

.color58C4CC{

background:#58C4CC url(../../static/images/kdt/icon-curriculum.png) no-repeat 530upx 45upx;

background-size: 125upx;

}

.color7E8FEF{

background:#7E8FEF url(../../static/images/kdt/icon-family.png) no-repeat 530upx 45upx;

background-size: 125upx;

}

.column {

width: 702upx;

height: 182upx;

margin:17upx auto;

padding-left: 25upx;

padding-top: 35upx;

line-height: 42upx;

letter-spacing: 4upx;

border-radius: 10upx;

.title{

color: #ffffff;

font-size: 31upx;

}

.txt{

width: 426upx;

font-size: 25upx;

color: #E6E6E6

}

}

//commom.js

export default{

kdtHomeHtmlJSON:[{

title:'体测数据录入',

txt:'体测数据现场“录入+上传”,一步到位!',

themColor:'colorA268D4'},

{

title:'入园师训',

txt:'提高幼师对于体育与运动领域基本知识,基本技能,实践操作能力',

themColor:'colorFA5E8A'},

{

title:'体能课程',

txt:'提升幼师对于体育与运动领域基本知识,基本技能,实践操作能力',

themColor:'color58C4CC'},

{

title:'家长工作',

txt:'确保每位家长都能收到孩子的体能成果',

themColor:'color7E8FEF'}]

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你想要优化uni-app的tab切换带折叠效果,可以考虑使用动画库或自定义动画来实现更加流畅和灵活的效果。下面是一个示例代码,使用了`animate.css`动画库和自定义过渡效果来优化tab切换的折叠效果: 首先,安装`animate.css`库,可以通过npm或者yarn进行安装: ```bash npm install animate.css ``` 然后,在uni-app的项目中创建一个新的组件,比如`TabCollapse.vue`: ```html <template> <view class="container"> <view class="tab-bar"> <view class="tab-item" :class="{ active: activeTab === 'tab1' }" @click="toggleTab('tab1')" > Tab 1 </view> <view class="tab-item" :class="{ active: activeTab === 'tab2' }" @click="toggleTab('tab2')" > Tab 2 </view> </view> <transition-group name="fade"> <view class="content" v-for="tab in tabs" :key="tab.name" v-show="activeTab === tab.name" > {{ tab.content }} </view> </transition-group> </view> </template> <script> import 'animate.css'; export default { data() { return { activeTab: 'tab1', tabs: [ { name: 'tab1', content: 'Content 1', }, { name: 'tab2', content: 'Content 2', }, ], }; }, methods: { toggleTab(tab) { if (this.activeTab === tab) { this.activeTab = ''; // 折叠当前展开的tab } else { this.activeTab = tab; // 切换到选中的tab } }, }, }; </script> <style> .container { display: flex; flex-direction: column; height: 100vh; } .tab-bar { display: flex; justify-content: space-between; padding: 16px; background-color: #f0f0f0; } .tab-item { padding: 8px 16px; border-radius: 4px; cursor: pointer; } .tab-item.active { background-color: #e0e0e0; } .content { padding: 16px; animation-duration: 0.3s; } .fade-enter-active, .fade-leave-active { animation-fill-mode: both; animation-timing-function: ease-in-out; } .fade-enter, .fade-leave-to { animation-duration: 0.3s; animation-delay: 0.1s; } .fade-enter { animation-name: fadeInDown; } .fade-leave-to { animation-name: fadeOutUp; } </style> ``` 在上面的代码中,我们使用了`animate.css`库来提供丰富的动画效果,通过添加过渡类名和自定义动画,使tab的切换效果更加流畅和优雅。在`<transition-group>`组件中使用`v-for`指令遍tabs数组,并使用`v-show`指令根据activeTab的值来控制显示和隐藏。 然后,在`<style>`标签中定义了过渡的动画效果。你可以根据需要选择合适的动画效果,也可以自定义自己的动画。 希望这个优化方案对你有帮助!如果有任何问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值