FinClip为企业提供小程序生态圈技术产品,开发者可在FinClip小程序开发帮助中心找到相关FinClip小程序指引

# 引用

FXML 提供两种文件引用方式importinclude

# 1. import

import可以在该文件中使用目标文件定义的template,如:

在 item.fxml 中定义了一个叫itemtemplate

<!-- item.fxml -->
<template name="item">
  <text>{{text}}</text>
</template>

在 index.fxml 中引用了 item.fxml,就可以使用item模板:

<import src="item.fxml"/>
<template is="item" data="{{text: 'forbar'}}"/>

# 2. import 的作用域

import 有作用域的概念,即只会 import 目标文件中定义的 template,而不会 import 目标文件 import 的 template。

如:C import B,B import A,在 C 中可以使用 B 定义的template,在B中可以使用 A 定义的template,但是 C 不能使用 A 定义的template

<!-- A.fxml -->
<template name="A">
  <text> A template </text>
</template>
<!-- B.fxml -->
<import src="a.fxml"/>
<template name="B">
  <text> B template </text>
</template>
<!-- C.fxml -->
<import src="b.fxml"/>
<template is="A"/>  <!-- Error! Can not use tempalte when not import A. -->
<template is="B"/>

# 3. include

include可以将目标文件除了<template/> <fxs/>外的整个代码引入,相当于是拷贝到 include位置,如:

<!-- index.fxml -->
<include src="header.fxml"/>
<view> body </view>
<include src="footer.fxml"/>
<!-- header.fxml -->
<view> header </view>
<!-- footer.fxml -->
<view> footer </view>
© 2022 FinClip with ❤

👋🏻 嘿,你好!

「FinClip」是一套基于云原生框架设计的小程序容器。能够让任何移动应用在集成小程序SDK之后,获得可用、安全的小程序运行能力。

>> 点我免费注册体验

查看产品文档
了解与 FinClip 相关的一切信息

产品博客 👈  了解产品更新与核心功能介绍
资源下载 👈  获取小程序 SDK 与开发工具
文档中心 👈  查询 FinClip 小程序开发指南与答疑

商务咨询热线
预约 FinClip 产品介绍,咨询商务报价或私有化部署事宜

0755-86967467

获取产品帮助
联系 FinClip 技术顾问,获取产品资料或加入开发者社群

联系线上
人工客服

或 👉  点击这里,提交咨询工单