Home > WeChat Applet > Mini Program Development > Detailed explanation and simple examples of WeChat Mini Program Template

Detailed explanation and simple examples of WeChat Mini Program Template

高洛峰
Release: 2017-01-10 10:11:30
Original
2260 people have browsed it

WeChat Mini Program Template

Template

WXML provides a template (Template), in which code snippets can be defined and then used in different places. The format and data can be guaranteed to be the same.

1-Define the template

Use the `` tag to define the template, name the template name tempName, and assign the value to the attribute name . Inside the tag, define the template structure. As follows:

<!-- template.wxml -->
<!--
  index: int
  msg: string
  time: string
-->
<template name="msgItem">
  <view>
  <text> {{index}}: {{msg}} </text>
  <text> Time: {{time}} </text>
 </view>
</template>
Copy after login

2-Use template

Use the