自定义元素与使用Aurelia中的require导入之间有什么区别

时间:2022-07-19 13:34:14

In the skeleton-nav app.html, the nav-bar is imported like a custom element using the require statement and can by used like a custom element using tags , but according to the docs you also need to define it by importing customelement or by using CustomElement convention. However, the nav-bar.js does not use customelement or the convention but you can still use it as a custom tag in your html. What is the difference between the nav-bar template and one defined using the customelement syntax. By using require on any template does this mean that it is automatically a custom element, is this another convention?

在skeleton-nav app.html中,导航栏使用require语句像自定义元素一样导入,并且可以像使用标签的自定义元素一样使用,但根据文档,您还需要通过导入customelement或通过使用CustomElement约定。但是,nav-bar.js不使用customelement或约定,但您仍然可以将它用作html中的自定义标记。导航栏模板与使用customelement语法定义的模板之间有何区别。通过在任何模板上使用require,这意味着它自动成为自定义元素,这是另一种惯例吗?

1 个解决方案

#1


I believe that the documentation is simply not up to date. Because in previous version i indeed needed to use the convention but as you said it is not necessary anymore. Just a camelcase name should be enough fir any custom element. But you still need the convention for the custom attribute I believe.

我认为文档根本不是最新的。因为在以前的版本中我确实需要使用约定,但正如你所说的那样,它已经不再需要了。只是一个camelcase名称应该足够任何自定义元素。但是你仍然需要我认为的自定义属性的约定。

#1


I believe that the documentation is simply not up to date. Because in previous version i indeed needed to use the convention but as you said it is not necessary anymore. Just a camelcase name should be enough fir any custom element. But you still need the convention for the custom attribute I believe.

我认为文档根本不是最新的。因为在以前的版本中我确实需要使用约定,但正如你所说的那样,它已经不再需要了。只是一个camelcase名称应该足够任何自定义元素。但是你仍然需要我认为的自定义属性的约定。