本篇文章给大家介绍一下微信小程序中import和include差别。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。
相关学习推荐:
import 有作用域的概念,即只会 import 目标文件中定义的 template,而不会 import 目标文件 import 的 template
<!-- A.wxml --> <template> <text> A template </text></template>
登录后复制
<!-- B.wxml --> <import></import><template> <text> B template </text></template>
登录后复制
<!-- C.wxml --> <import></import><template></template> <!-- 错误不能多级引用A --> <template></template>
登录后复制
include 可以将目标文件除了 外的整个代码引入,相当于是拷贝到 include
<!-- index.wxml --> <include></include><view> body </view><include></include>
登录后复制
<!-- header.wxml --> <view> header </view>
登录后复制
<!-- footer.wxml --> <view> footer </view>
登录后复制
更多编程相关知识,请访问:!!
以上就是小程序中import和include有什么区别的详细内容,更多请关注GTHOST其它相关文章!