


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

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools