0

我有一個基本的奧裏利亞組件,它看起來像當我在它的名稱中使用破折號,它不起作用。奧裏利亞破折號在組件名稱不起作用

它工作時,我有這樣的:當是這樣

import {inject, customElement, bindable} from 'aurelia-framework'; 

@customElement('helloworld') 
@inject(Element) 
export class HelloWorldCustomElement { 
    constructor(element) { 
     console.log ('here') 
    } 
} 
<helloworld></helloworld> 

但事實並非如此:

import {inject, customElement, bindable} from 'aurelia-framework'; 

@customElement('hello-world') 
@inject(Element) 
export class HelloWorldCustomElement { 
    constructor(element) { 
     console.log ('here') 
    } 
} 
<hello-world></hello-world> 

根據Aurelia文檔,它應該可以同時工作:https://github.com/aurelia/templating/blob/master/doc/article/en-US/templating-custom-elements.md

+0

你確定你沒有在你的一個應用另一個'HELLO-world'成分,特性? –

+0

這似乎是這種情況。我正在導入一個與導致衝突的名稱相同的HTML文件:'' – st3fan

回答

1

我設法找到原因。在app.html我有以下行,似乎有一個命名衝突。刪除它可以立即解決問題。

<require from="hello-world/hello-world.html"></require> 
+3

另外值得注意的是,您不需要使用'customElement '裝飾者,如果你通過'MyElementCustomElement'使用默認的命名約定,反之亦然。裝飾器給你更多的控制,並允許你爲元素命名爲不同的類。 –