Reference of WeChat mini-app tutorial and Wechat mini-app reference

Source: Internet
Author: User

References of mini-program tutorials and mini-program references

Series of articles:

Mini-program tutorial-WXSS
References to mini-program tutorials
Events of mini-program tutorials
Small Program tutorial Template
List rendering of Applet tutorials
Conditional rendering of mini-program tutorials
Data Binding in applet tutorial
Mini-program tutorial-WXML

Reference

WXML provides two file reference methods: import and include.

Import

Import can use the template defined in the target file in this file, for example:

A template named item is defined in item. wxml:

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

You can use the item template by referencing item. wxml in index. wxml:

<import src="item.wxml"/><template is="item" data="{{text: 'forbar'}}"/>

Scope of import

Import has the concept of scope, that is, only the template defined in the target file will be imported, rather than the template of the target file import.
For example, C import B, B import A. in C, you can use the template defined by B. In B, you can use the template defined by A, but C cannot use the template defined by.

<!-- 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:

<!-- 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 this article. I hope it will help you. Thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.