Home > Article > WeChat Applet > Detailed explanation of WXML for small program development
WXML (WeiXin Markup Language) is a set of tag languages designed by the MINA framework. Combined with basic components and event systems, it can build the structure of the page.
Use some simple examples below to see what capabilities WXML has:
Data binding
<!--wxml--><view> {{message}} </view> // page.jsPage({ data: { message: 'Hello MINA!' } })
List rendering
<!--wxml--><view wx:for-items="{{array}}"> {{item}} </view> // page.jsPage({ data: { array: [1, 2, 3, 4, 5] } })
Conditional rendering
<!--wxml--><view wx:if="{{view == 'WEBVIEW'}}"> WEBVIEW </view><view wx:elif="{{view == 'APP'}}"> APP </view><view wx:else="{{view == 'MINA'}}"> MINA IS NOT APP </view> // page.jsPage({ data: { view: 'MINA' } })
Template
<!--wxml--><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.jsPage({ data: { staffA: {firstName: 'Hulk', lastName: 'Hu'}, staffB: {firstName: 'Shang', lastName: 'You'}, staffC: {firstName: 'Gideon', lastName: 'Lin'} } })
Event
<view bindtap="add"> {{count}} </view> Page({ data: { count: 1 }, add: function(e) { this.setData({ count: this.data.count + 1 }) } })
[Related recommendations]
1. WeChat applet complete source code download
2. Simple left swipe operation and waterfall flow layout
3. Chaige WeChat Mini Program App Store Source Code
The above is the detailed content of Detailed explanation of WXML for small program development. For more information, please follow other related articles on the PHP Chinese website!