简体   繁体   中英

Aurelia dash in component name not working

I have a basic Aurelia component and it looks like when I use dash in it's name, it doesn't work.

It works when I have it like this:

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

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

But it doesn't when is like this:

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

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

According to the Aurelia docs, it should work both ways: https://github.com/aurelia/templating/blob/master/doc/article/en-US/templating-custom-elements.md

I managed to find the cause for this. In app.html I had the following line and it appears that there was a naming conflict. Removing it fixed the problem right away.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM