当前位置:网站首页>[wechat applet] how did the conditional rendering list render work?
[wechat applet] how did the conditional rendering list render work?
2022-06-30 03:09:00 【Xiaobai who loves programming】
Catalog
WXML Template syntax - Conditions apply colours to a drawing
WXML Template syntax - The list of rendering
2. Manually specify the index and the variable name of the current item
WXML Template syntax - Conditions apply colours to a drawing
1. wx:if
<view wx:if="{
{condition}}">ture</view>
<view wx:if="{
{type==1}}">type==1</view>
<view wx:elif="{
{type==2}}">type==2</view>
<view wx:else>type==3</view>
js:
Page({
data: {
type:1
},
})
because type The value of is 1, therefore :
for example :
WXML:
<view wx:if="{
{type==1}}"> Main tone </view>
<view wx:elif="{
{type==2}}"> General button </view>
<view wx:else> nothing </view>
<button type="primary" size="mini" wx:if="{
{type==1}}"> Main tone </button>
<button size="mini" wx:if="{
{type==2}}"> General button </button>
JS It's the same as up here
effect :
2. combination <block> Use wx:if
<block wx:if="{
{true}}">
<view>view1</view>
<view>view2</view>
<view>view3</view>
</block>
3. hidden
<view hidden="{
{false}}">hidden</view>
hidden in false Indicates that the component is not hidden
4. wx:if And hidden Comparison of
WXML Template syntax - The list of rendering
🥭1. wx:for
<view wx:for="{
{arry}}">
The index is :{
{index}},item Item is :{
{item}}
</view>
JS:
Page({
data: {
arry:[' a mandarin orange ',' Apple ',' Banana ']
}
})

2. Manually specify the index and the variable name of the current item

3. wx:key Use
<view wx:for="{
{userList}}" wx:key="id">
{
{item.name}}
</view>
JS:
Page({
data: {
userList:[
{id:1,name:' heat '},
{id:2,name:' Love '},
{id:3,name:' Ed '},
{id:4,name:' cheng '},
{id:5,name:' Of '},
{id:6,name:' Small '},
{id:7,name:' white '},
{id:8,name:' white '},
]
}
})
effect :
边栏推荐
- Uniapp address translation latitude and longitude
- Utf8 error in Oracle migration of Jincang Kingbase database
- Threejs mirror case reflector create mirror + house construction + small ball movement
- 问题记录:fel_lib.c:26:10: fatal error: libusb.h: 没有那个文件或目录
- JvxeTable子表记录加载完毕事件
- Compile a DLL without import table
- Use of custom MVC
- What are outer chain and inner chain?
- C console format code
- How to prevent duplicate submission under concurrent requests
猜你喜欢
The MariaDB database was found 12 hours late
怎么利用Redis实现点赞功能
How to use redis to realize the like function
【微信小程序】条件渲染 列表渲染 原来这样用?
Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing
mysql 主从数据库同步失败的原因
How to switch ipykernel to a different CONDA virtual environment in jupyterlab?
Simple custom MVC
High paid programmers & interview questions series 63: talk about the differences between sleep (), yield (), join (), and wait ()
An article to get you started VIM
随机推荐
简单自定义MVC优化
On the role of database tables
原生JS怎么生成九宫格
Mysql提取表字段中的字符串
HOOK Native API
Three solutions to forced hibernation of corporate computers
High paid programmers & interview questions series 63: talk about the differences between sleep (), yield (), join (), and wait ()
hudi记录
Auto. JS learning notes 16: save to the mobile phone by project, instead of saving a single JS file every time, which is convenient for debugging and packaging
Study diary: February 15, 2022
O & M (21) make winpe startup USB flash disk
How to set password complexity and timeout exit function in Oracle
Data set preparation and arrangement
Lua Basics
C console format code
uniapp 地址转换经纬度
Golang BiliBili live broadcast bullet screen
[oiclass] chess piece
华为面试题: 高矮个子排队
什么是外链和内链?