formatd / componentloader
为 Fusion 组件自动加载 JavaScript
v1.0.3
2024-04-11 14:33 UTC
Requires
- neos/neos: >=7.0
README
为融合组件加载 JavaScript 的简单方法
兼容性
版本控制方案
1.0.0
| | |
| | Bugfix Releases (non breaking)
| Neos Compatibility Releases (non breaking)
Feature Releases (breaking)
版本和兼容性
使用方法
FormatD.ComponentLoader:WindowComponentRegistry
会自动放置在 Neos.Neos:Page 的头部。
为 @packages
创建一个 typescript-include-alias,它指向 composer 包夹。
在你的组件中使用原型
prototype(Vendor.Website:MyComponent) < prototype(FormatD.ComponentLoader:Component) {
...
}
创建一个组件管理器
import { AbstractComponentManager } from "@packages/Application/FormatD.ComponentLoader/Resources/Private/TypeScript/AbstractComponentManager" export default class MyComponentManager extends AbstractComponentManager { initialize(domSection: HTMLElement) { console.log("Hello World") } }
包含相应的文件
import {componentLoader} from "@packages/Application/FormatD.ComponentLoader/Resources/Private/TypeScript/ComponentLoader"; componentLoader.addDefaultImport('Vendor.Website:MyComponent', () => import('../private/Fusion/MyComponent')); //... componentLoader.initialize()
可选的回调可以用来自初始化由组件管理器不管理的自定义 JavaScript
componentLoader.initialize(async (domSection, reason) => { if (domSection.querySelector('myElement')) { // add stuff here } });