elements

AMD: require(["geoscene/form/support/elements"], (elements) => { /* 代码 */ });
ESM: import * as elements from "@geoscene/core/form/support/elements";
对象: geoscene/form/support/elements
起始版本: GeoScene API for JavaScript 4.22

一个方便的模块,用于在使用 TypeScript 进行开发时导入 Element 类。例如,与其像这样一次导入一个表单元素,不如这样:

import FieldElement from "geoscene/form/elements/FieldElement";
import GroupElement from "geoscene/form/elements/GroupElement";

您可以使用此模块将它们导入到一行上:

import { FieldElement, GroupElement } from "geoscene/form/elements";

此模块还允许您在表单元素上实现类型保护,从而使代码更加智能。

import { Element } from "geoscene/form/elements";

function logFormElement(element: Element): void {
  if (element.type === "field") {
    console.log("Form element type is field");
  }
  else {
    // The compiler knows the content element must be `field | group`
    console.log("The value is not a valid form element.")
  }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.