Last updated: 2024-11-21 18:34:18
WXML is a markup language for framework design. It can be used to build the page structure when combined with API Overview and an event system. Data Binding
<view> {{message}} </view>
Page({
data: {
message: 'Hello MINA!'
}
})
List Rendering
<view wx:for="{{array}}"> {{item}} </view>
Page({
data: {
array: [1, 2, 3, 4, 5]
}
})
Conditional Rendering
<view wx:if="{{view == 'WEBVIEW'}}"> WEBVIEW </view>
<view wx:elif="{{view == 'APP'}}"> APP </view>
<view wx:else="{{view == 'MINA'}}"> MINA </view>
Page({
data: {
view: 'MINA'
}
})
Template
<template name="staffName">
<view>
FirstName: {{firstName}}, LastName: {{lastName}}
</view>
</template>
<template is="staffName" data="{{...staffA}}"></template>
<template is="staffName" data="{{...staffB}}"></template>
<template is="staffName" data="{{...staffC}}"></template>
Page({
data: {
staffA: {firstName: 'Hulk', lastName: 'Hu'},
staffB: {firstName: 'Shang', lastName: 'You'},
staffC: {firstName: 'Gideon', lastName: 'Lin'}
}
})
Was this page helpful?