Introduction to FXML
FXML (Neuxnet Markup Language) is a set of tag languages designed by the framework, combined with basic components and event systems, to build the structure of the page.
Let's take a look at what FXML is capable of with some simple examples:
# 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>
<view wx:else="{{view == 'MINA'}}"> Neuxnet </view>
page.js
Page({
data: {
view: 'Neuxnet'
}
})
# 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 how to use them can be found in the various sections of this table of contents.
Last update: 2022/08/11, 21:35:51