uniapp设置动态样式的方法:1。用户点击按钮后,动态切换按钮选择样式;2.给标签渲染各种颜色,代码是[。sign style-0 { color:# 3 AC 9e 3;边框:1px实心# 3ac9e3}】。
本教程操作环境:windows7系统,uni-app版本2.5.1,此方法适用于所有品牌的电脑。
推荐(免费):统一应用开发教程
Uniapp设置动态样式的方法:
场景1:点击按钮后,用户动态切换按钮选择样式(如图)
& ltview class = & quot状态-BTN-内容& quot>。& lt查看@ tap = & quot选择状态& quot数据状态= & quot超过& quot:class = & quot[what selected = = & # 39;超过& # 39;?'state-BTN-select & # 39;:'state-BTN-nosel & # 39;]& quot;>。在线的
错误演示:
场景2:为标签渲染多种颜色(如图)
& lt视图:class = & quot['每个标志项目& # 39;,` sign style-$ { index % 6 } `] & quot;v-for = & quot;预分配列表中的(项目,索引):键= & quot索引& quot>。{ { item.name } } & lt/view>。。every-sign-item { padding:4rpx 16rpx;边界半径:24rpxfont-size:24 rpx;右边距:20rpx边缘-底部:20rpx}.sign style-0 { color:# 3 AC 9e 3;边框:1px实心# 3ac9e3}.sign style-1 { color:# FD 8888;边框:1px实心# fd8888}.signstyle-2 {...}.signstyle-3 {...}.signstyle-4 {...}.signstyle-5 {...}以上是如何在uniapp中设置动态样式的细节,还有更多。