Home >WeChat Applet >Mini Program Development >What is the difference between import and include in a mini program?
This article will introduce to you the difference between import and include in WeChat applet. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Related learning recommendations: Small Program Development Tutorial
import has the concept of scope, that is, it will only import the definitions in the target file The template of import will not import the target file. The template of import
<!-- 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"/> <!-- 错误不能多级引用A --> <template is="B"/>
include can introduce the entire code except the target file, which is equivalent to copying to include
<!-- index.wxml --> <include src="header.wxml"/> <view> body </view> <include src="footer.wxml"/>
<!-- header.wxml --> <view> header </view>
<!-- footer.wxml --> <view> footer </view>
For more programming-related knowledge, please Visit: Introduction to Programming! !
The above is the detailed content of What is the difference between import and include in a mini program?. For more information, please follow other related articles on the PHP Chinese website!