import可以加载已经定义好的template。item.axml中定义了一个叫item的template。<!-- item.axml -->
<template name="item">
<text>{{text}}</text>
</template>index.axml中引用item.axml,就可以使用item模板。<import src="./item.axml"/>
<template is="item" data="{{text: 'forbar'}}"/>import有作用域的概念,只会import目标文件中定义的template。比如,C import B,B import A,在C中可以使用B定义的template,在B中可以使用A定义的template,但是C不能使用A中定义的template。<!-- A.axml -->
<template name="A">
<text> A template </text>
</template><!-- B.axml -->
<import src="./a.axml"/>
<template name="B">
<text> B template </text>
</template><!-- C.axml -->
<import src="./b.axml"/>
<template is="A"/> <!-- Error! Can not use tempalte when not import A. -->
<template is="B"/><template name="x">
<view />
</template><template name="x">
<view />
<view />
</template>include可以将目标文件除了<template/>的整个代码引入,相当于是拷贝到include位置。<!-- index.axml -->
<include src="./header.axml"/>
<view> body </view>
<include src="./footer.axml"/><!-- header.axml -->
<view> header </view><!-- footer.axml -->
<view> footer </view>