search
HomeWeChat AppletMini Program DevelopmentWeChat applet reference tutorial

WeChat applet reference tutorial

May 15, 2018 am 10:20 AM
ExampleQuoteWeChat applet

This article mainly introduces the relevant information cited by WeChat applet, and attaches simple example code. Friends in need can refer to the

series of articles:

WXSS of WeChat applet tutorial
Quotation of WeChat Mini Program Tutorial
Events of WeChat Mini Program Tutorial
Template of WeChat Mini Program Tutorial
List Rendering of WeChat Mini Program Tutorial
Conditional Rendering of WeChat Mini Program Tutorial
Data Binding of WeChat Mini Program Tutorial
WXML of WeChat Mini Program Tutorial

Reference

WXML provides two file reference methods, import and include.

import

import can use the template defined by the target file in this file, such as:

in item.wxml A template called item is defined in:

<!-- item.wxml -->
<template name="item">
 <text>{{text}}</text>
</template>

If item.wxml is referenced in index.wxml, you can use the item template:

<import src="item.wxml"/>
<template is="item" data="{{text: &#39;forbar&#39;}}"/>

import scope

Import has the concept of scope, that is, it will only import the template defined in the target file, but not the template imported by the target file.
For example: C import B, B import A, the template defined by B can be used in C, and the template defined by A can be used in B, but C cannot use the template defined by A.

<!-- A.wxml -->
<template name="A">
 <text> A template </text>
</template>
<!-- B.wxml -->
<import src="a.wxml"/>
<template name="B">
 <text> B template </text>
</template>
<!-- C.wxml -->
<import src="b.wxml"/>
<template is="A"/> <!-- Error! Can not use tempalte when not import A. -->
<template is="B"/>

include

include can introduce the entire code of the target file out of , which is equivalent to copying to the include location, such as:

<!-- index.wxml -->
<include src="header.wxml"/>
<view> body </view>
<include src="footer.wxml"/>
<!-- header.wxml -->
<view> header </view>
<!-- footer.wxml -->
<view> footer </view>

Thank you for reading, I hope it can help everyone, thank you everyone for your support of this site!

The above is the detailed content of WeChat applet reference tutorial. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools