开发者社区
社区提问意见反馈
开发者钉组织
扫描二维码
加入支付宝开发者钉组织
native 渲染
性能与优化
小程序全局配置
小程序页面
axml
sjs 语法参考
事件系统
自定义组件
基础能力
基础库
基础库更新日志
开发 > 框架 >  > 引用
贡献者
收藏
订阅更新
我的文档
设置
axml 提供两种文件引用方式 importinclude
import
import 可以加载已经定义好的 template
例如,在 item.axml 中定义了一个叫 itemtemplate
html
复制代码
<template name="item">
<text>{{text}}text>
template>
在 index.axml 中引用 item.axml,就可以使用 item 模板。
html
复制代码
<import src="./item.axml"/>
<template is="item" data="{{text: 'forbar'}}"/>
import 有作用域的概念,只会 import 目标文件中定义的 template,而不会 import 目标文件 import 的 template。
例如,c import b,b import a,在 c 中可以使用 b 定义的 template,在 b 中可以使用 a 定义的 template,但是 c 不能使用 a 中定义的 template。
html
复制代码
<template name="a">
<text> a template text>
template>
html
复制代码
<import src="./a.axml"/>
<template name="b">
<text> b template text>
template>
html
复制代码
<import src="./b.axml"/>
<template is="a"/>
<template is="b"/>
include
include 可以将目标文件除
网站地图