Mini App Document Mini App Document
  • Start
  • Configuration
  • Framework
  • Custom Components
  • Basic ability
  • Configuration
  • Interface
  • FXML syntax
  • FXS syntax
API
Components
IDE
  • Developer
  • Operator
  • Start
  • Configuration
  • Framework
  • Custom Components
  • Basic ability
  • Configuration
  • Interface
  • FXML syntax
  • FXS syntax
API
Components
IDE
  • Developer
  • Operator
  • Configuration

  • Interface

  • FXML syntax

    • Introduction to FXML
    • Data binding
    • List rendering
    • Conditional rendering
    • Template
    • Quote
      • 1. import
      • 2. The scope of import
      • 3. include
  • FXS syntax

  • Framework
  • FXML syntax
2022-08-09
Directory

Quote

FXML provides two ways to refer to files 'import' and 'include'.

# 1. import

'import' can use the 'template' defined by the target file in the file, such as:

In item.fxml defines a 'template' called 'item':

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

With an item.fxml referenced in index.fxml, you can use the 'item' template:

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

# 2. The scope of import

import has the concept of scope, that is, only the template defined in the target file is imported, not the template imported in the target file.

**For example: C import B, B import A, you can use the 'template' defined by B in C, you can use the 'template' defined by A in B, but C cannot use the 'template' defined by A. **

<!-- 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' can introduce the entire code of the target file except '' ''' to copy it to the 'include' location, such as:

<!-- index.fxml -->
<include src="header.fxml"/>
<view> body </view>
<include src="footer.fxml"/>
<!-- header.fxml -->
<view> header </view>
<!-- footer.fxml -->
<view> footer </view>
Last update: 2022/08/11, 20:42:12
Template
Introduction to FXS

← Template Introduction to FXS→

Copyright © 2020-2024 Neuxnet
  • Follow System
  • Light Mode
  • Dark Mode
  • Reading Mode