# FXML Introduction
FXML (Markup Language) is a markup language designed by the framework, which, combined with basic components and the event system, can construct the structure of pages.
Let's look at some simple examples to see what capabilities FXML possesses:
# 1. Data Binding
<!--fxml-->
<view> {{message}} </view>
// page.js
Page({
data: {
message: 'Hello World!'
}
})
# 2. List Rendering
<!--fxml-->
<view wx:for="{{array}}"> {{item}} </view>
// page.js
Page({
data: {
array: [1, 2, 3, 4, 5]
}
})
# 3. Conditional Rendering
<!--fxml-->
<view wx:if="{{view == 'WEBVIEW'}}"> WEBVIEW </view>
<view wx:elif="{{view == 'APP'}}"> APP </view>
// page.js
Page({
data: {
view: 'APP'
}
})
# 4. Template
<!--fxml-->
<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.js
Page({
data: {
staffA: {firstName: 'Alex', lastName: 'Wang'},
staffB: {firstName: 'Yuran', lastName: 'Wu'},
staffC: {firstName: 'Arron', lastName: 'Liu'}
}
})
Specific capabilities and usage methods can be viewed in the respective chapters within this directory.