ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 模版引用 ### import import可以在该文件中使用目标文件定义的template ``` <!-- item.wxml --> <template name="item"> <text>{{text}}</text> </template> ``` > 引用模板 ``` <import src="item.wxml"/> <template is="item" data="{{text: 'forbar'}}"/> ``` #### import 的作用域 import 有作用域的概念,即只会 `引用` 目标文件中定义的 template,而不会 `引用 `目标文件 `引用`的 template。 ``` 如: A<B<C C引用了B B引用了A C不能直接 <template is="A"> </template> ``` ## include include 可以将目标文件除了 `<template/> <wxs/> `外的整个代码引入,相当于是拷贝到 include 位置,如: ``` <!-- index.wxml --> <include src="header.wxml"/> <view> body </view> <include src="footer.wxml"/> ``` ``` <!-- header.wxml --> <view> header </view> ``` ``` <!-- footer.wxml --> <view> footer </view> ```