aurelia自定义插件,使用自定义属性 – 不能find自定义属性

嗨,我已经从https://github.com/aurelia/skeleton-plugin下载了hello world aurelia skelton插件。 然后我从package.json文件中引用这个新的aurelia esnext / webpack skelton副本( https://github.com/aurelia/skeleton-navigation/tree/master/skeleton-esnext-webpack )作为我的主应用程序。 然后我可以在我的组件之一中使用插件

<require from="aurelia-skeleton-plugin/hello-world"></require> 

在视图的顶部,并在视图的任何位置放置<hello-world></hello-world> 。 这工作很好。

下一步我想尝试添加一个自定义属性到我的插件。 在我的插件的src文件夹中,我添加了简单的自定义属性

 export class RedSquareCustomAttribute { static inject = [Element]; constructor(element){ this.element = element; this.element.style.width = this.element.style.height = '100px'; this.element.style.backgroundColor = 'red'; } } 

然后我用下面的代码在hello-world.html页面中引用它

 <require from="./red-square"></require> <div red-square></div> 

运行gulp生成,然后重新安装在我的主要应用程序包。 在主应用程序npm开始build立好,但浏览器给我的错误:无法find模块'./aurelia-skeleton-plugin/red-square'

我阅读了大量的文档,但没有给出这种情况的例子,任何帮助将不胜感激。

以下是一些可以尝试的方法 – 尽pipe我已经从您提供的链接中的教程中获得了这些信息。

确认config.js中的classProperties具有classProperties

  babelOptions: { "optional": [ "runtime", "optimisation.modules.system", "es7.classProperties" ] }, 

接下来,请仔细检查您的文件是否正确放置在src文件夹中,并命名为:

  • red-sqaure.js
  • simple-attribute-usage.html

然后,无论哪个HTML文件都有您的内容 – 您的shell / app,请执行以下操作:

<compose view="simple-attribute-usage.html" viewmodel="red-square"></compose>

虽然我能够得到原始的HTML工作

 <require from="./red-square"></require> <div red-square></div>