小组件开发者工具 1.59.27,基础库 3.16.4 开始支持改能力
xhsml 提供两种文件引用方式
在
<!-- item.xhsml --> <template name="item"> <text>{{text}}</text> </template>
在
<import src="item.xhsml"/> <template is="item" data="{{text: 'forbar'}}"/>
如:C import B,B import A,在 C 中可以使用 B 定义的 template,在 B 中可以使用 A 定义的 template,但是 C 不能使用 A 定义的 template。
<!-- A.xhsml --> <template name="A"> <text> A template </text> </template>
<!-- B.xhsml --> <import src="a.xhsml"/> <template name="B"> <text> B template </text> </template>
<!-- C.xhsml --> <import src="b.xhsml"/> <template is="A"/> <!-- Error! Can not use tempalte when not import A. --> <template is="B"/>
<!-- index.xhsml --> <include src="header.xhsml"/> <view> body </view> <include src="footer.xhsml"/>
<!-- header.xhsml --> <view> header </view>
<!-- footer.xhsml --> <view> footer </view>