我在 github 存储库中定义了一个自定义元素。然后我jspm install
'd 在另一个应用程序中说过元素。
在其他应用程序中导入此元素的正确方法是什么?当我调用aurelia.use.plugin('aurelia-custom-element')
时在应用程序配置中,它说找不到 aurelia-custom-element.js
.
aurelia-custom-element.html:
<template>
<div>Hello world, from Aurelia custom element!</div>
</template>
aurelia-custom-element.js:
import {customElement, bindable} from 'aurelia-framework';
@customElement('aurelia-custom-element')
export class AureliaCustomElement {
}
index.js:
export * from './aurelia-custom-element';
export function configure(config){
config.globalResources('./aurelia-custom-element');
}
最佳答案
您放置的内容 aurelia.use.plugin('[here]')
应与您安装的 jspm 相匹配。
例如,如果包含您的插件的 github 存储库是 https://github.com/uavalos/mega-plugin ,您可以执行 jspm install github:uavalos/mega-plugin 来安装插件。要加载插件,您需要编写aurelia.use.plugin('uavalos/mega-plugin')
。
如果您分享您的插件的网址,我可以提供更具体的帮助。
关于javascript - 如何在 Aurelia 应用程序中使用外部自定义元素(插件)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33050252/