当前位置:网站首页>微信小程序动态样式|参数传递
微信小程序动态样式|参数传递
2022-07-19 05:01:00 【极速小乌龟】
<ul class="item-list">
<li wx:for="{
{periodList}}" wx:for-item="period"
wx:key="id"
class="item {
{currentPeriodId == period.id?'active':''}}"
data-id="{
{period.id}}"
bindtap="choosePeriod">{
{period.name}}</li>
</ul>
直接在class中通过{ {}}和判断条件加载,花括号中使用三目表达式进行判断,如果为true则显示active样式,如果为false不显示active样式
使用data- 传递参数,比如我现在传递id 那就是data-id="{ {}}",
如果传递name那就是data-name="{ {}}"
后台接收方式为:
choosePeriod:function(e){
console.log(e.currentTarget.dataset.id)
},
边栏推荐
- 太卷了, 某公司把自家运营多年的核心系统(智慧系统)完全开源了....
- CSimpleArray
- Report on Market Research and investment prospects of China's yellow blood salt and potassium industry (2022 Edition)
- [transfer] pyhton__ pycache__ Generation and function of folders
- 【MATLAB appdesigner】27_如何在appdesigner中调试,查看变量?(举例+技巧)
- 如何区分固态硬盘和机械硬盘
- TCP与UDP的区别
- Static keyword
- selnium 获取js内容
- 使用wireshark常用的过滤命令
猜你喜欢
如何定制.NET6.0的日志记录
AI识万物:从0搭建和部署手语识别系统
nodejs面经
YOLOv5改进之二十一:CNN+Transformer——主干网络替换为又快又强的轻量化主干EfficientFormer
太卷了, 某公司把自家运营多年的核心系统(智慧系统)完全开源了....
输入文本自动生成图像,太好玩了!
CacheManager - 用 C# 编写的 .NET 的开源缓存抽象层
Flask framework - model relationships (many to many)
Kuzaobao: summary of Web3 encryption industry news on July 18
What are the main "work contents" and responsibilities of software test engineers?
随机推荐
Etcd database source code analysis -- ServerV2 interface implementation
Flask send_ Absolute path traversal caused by file function
CSimpleArray
C# 基础(二)
Ar beauty platform youcam supports real-time preview of male beard
CnosDB 涅槃重生:弃用Go, 全面拥抱Rust
Unityvr -- robot scene 2- robot
Review in the fifth week
2022.7.17-----leetcode. five hundred and sixty-five
HCIP --- 重发布
Development and testing standard (simple version)
What are the main aspects of interface testing? What skills are needed? How to learn?
stm32 sct内存控制
接口测试主要测试哪方面?需要哪些技能?要怎么学习?
.NET 全场景开发终于到来了
Applet container technology is added to the mixed app development queue, and the cross end development efficiency is improved by 100%
C# 禁用 全局快捷键
Where is Jay Chou's album "the greatest work"? Dangbei box enjoys chairman Zhou's latest MV
基于.NET动态编译技术实现任意代码执行
CSimpleArray