Javascript 组件名称中的Aurelia破折号不工作
我有一个基本的Aurelia组件,当我在它的名字中使用dash时,它看起来不起作用 当我有这样的设备时,它就工作了:Javascript 组件名称中的Aurelia破折号不工作,javascript,aurelia,Javascript,Aurelia,我有一个基本的Aurelia组件,当我在它的名字中使用dash时,它看起来不起作用 当我有这样的设备时,它就工作了: import {inject, customElement, bindable} from 'aurelia-framework'; @customElement('helloworld') @inject(Element) export class HelloWorldCustomElement { constructor(element) { con
import {inject, customElement, bindable} from 'aurelia-framework';
@customElement('helloworld')
@inject(Element)
export class HelloWorldCustomElement {
constructor(element) {
console.log ('here')
}
}
import {inject, customElement, bindable} from 'aurelia-framework';
@customElement('hello-world')
@inject(Element)
export class HelloWorldCustomElement {
constructor(element) {
console.log ('here')
}
}
根据Aurelia文档,这应该是双向的:我设法找到了原因。在app.html中,我有下面一行,似乎有命名冲突。移除它立即解决了问题
<require from="hello-world/hello-world.html"></require>
还值得注意的是,如果通过MyElementCustomElement使用默认命名约定,则不需要使用customElement装饰器,反之亦然。装饰器为您提供了更多的控制,并允许您对元素使用不同名称的类。您确定应用程序中没有其他hello world组件或属性吗?似乎就是这样。我正在导入一个同名的HTML文件,导致冲突:
<hello-world></hello-world>
<require from="hello-world/hello-world.html"></require>