


This article will give you a detailed explanation of WXML in the entry-level development of small programs. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Introduction to the development framework
The development framework of the small program is composed of four major parts: Composed of WXML, WXSS, WXS, and Java Script.
1. WXML is used to describe the content of the page;
2. WXSS describes the page style;
3. JS is used to handle user logic and data communication;
4. WXS is a manifestation of the enhancement of WXML capabilities. It can perform calculations on the requested data to help wxml quickly build the structure of the page;
WXML syntax
WXML(weixin markup language)
name>
WXML features
WXML has four language features in total , respectively data binding, list rendering, conditional rendering and template reference
1. Data binding:
<!--index.wxml--> <view> <text>{{message}}</text> </view> --------------------------------------------------- <!--index.js--> Page ( { data: { message:"Hello,world!" } } )
2. List rendering
<!--index.wxml--> <view> <block wx:for="{{items}}" wx:for-item="{{item}}" wx:key="index"> <view>{{index}}:{{item.name}}</view> </block> </view> ------------------------------------------ <!--index.js--> Page ( { data: { items:[ {name:"商品A"} {name:"商品B"} ] } } )
3. Conditional rendering
<!--index.xwml--> <view>今天吃什么?<view> <view wx:if="{{condicition===1}}">当然是吃饺子啦!</view> <view wx:elif="{{condicition===2}}">可以考虑吃面条!</view> <view wx:else>米饭把米饭吧</view> ----------------------------------------------------------- <!--index.js--> Page ( { data: { condicition:Math.floor(Math.random()*3+1) } } )
4. Templates and references
<!--index.wxml 模板--> <template name="template"> <view> <view>收件人:{{name}}</view> <view>联系方式:{{phone}}</view> <view>地址:{{address}}</view> </view> </template> <template is="template" data="{{...item}}" ></template> -------------------------------------------------------------------- <!--index.js--> Page ( { data: { item: { name="张三", photo="1212123", address="China" } } } )
<!--index.wxml 引用--> <import src="a.wxml"></import> <template is="a"></template> <!--a.wxml--> <view>Hello,world</view> <template name="a"> Hello World! </template>
Note: References cannot be nested
<!--index.wxml--> <include src="a.wxml"> <template is="a"></template> </include> ------------------------------------ <!--a.wxml--> <template name="a"> <view>This is a.wxml</view> </template> <view>hello world</view>
Note: include copies all content except the master
This article is reproduced from: https://blog.csdn.net/yue__shen/article/details/90384729
Recommended: "小program Development Tutorial》
The above is the detailed content of Introduction to Mini Program Development: Understanding WXML. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
