Component template (public) reference of WeChat applet Official document
about reference:
https://mp.weixin.qq.com/debug/wxadoc/dev/framework/view/wxml/import.html
① The include
include of the reference method can be Import the entire code except the target file, which is equivalent to copying it to the include location
Example
Create a common template page
write something in wxml
<text>1111111111111111111</text>
Another page is ready to import this component
at the location where it wants to import
<include src="../publicsth/publicsth" />
Done,
but include has no effect on template templates
②The import import of the reference method can use the template example
defined by the target file in the file. Two templates are written in one page
<template name="footer1">
2222222222
</template>
<template name="footer2">
2222222222333333333333333333
</template>
another page wants to introduce it
<import src="../publicsth/footer" />
<template is="footer1"/>
<template is="footer2"/>
Finish
Note:
The scope of
import Import has the concept of scope, that is, only the template defined in the target file will be imported, and the template imported by the target file will not be imported.
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.