In-depth analysis of how to use mini program templates

青灯夜游
Release: 2021-10-09 10:39:56
forward
5368 people have browsed it

This article will give you a detailed understanding of the usage of the mini program template. I hope it will be helpful to you!

In-depth analysis of how to use mini program templates

#WXML provides templates, in which code snippets can be defined and then called in different places. [Related learning recommendations:小program development tutorial]

Preface

You will gain

  • How to use the small program template

  • Handling of mini program template data and events

  • Some precautions and optimization of mini program templates

Basic use of templates

Creating template files

Create a template folder in the page. You can use the mini program development tool [New Page] to quickly create files

In-depth analysis of how to use mini program templates

Note: When calling the template, only the wxml and wxss files work, and the JS files in the template do not work. The logic in the template must be processed in the filecalled by.

Create files can be designed according to your own project, this is not always the case

Define template

InDefine code snippets within, using the name attribute as the name of the template.

Copy after login

Using templates

To use templates in wxml, there are two steps

1), declaration, key import tag

2), use, Key is attribute