在使用 Aurelia 一段时间后,我正在尝试创建一个自定义组件/模板。然而,使用下面的最少代码,我似乎仍然无法显示 testcomponent.html
中的消息。 。我看到<testcomponent></testcomponent>
在 html DOM 中,但不是消息 test
。我做错了什么?
integrationcomponent.html
<template>
<require from="./forms/testcomponent"></require>
<h1>first page</h1>
<testcomponent></testcomponent>
</template>
testcomponent.js
export class TestComponent {
constructor() {
}
}
testcomponent.html
<template>
<p>test</p>
</template>
最佳答案
类名为 TestComponent;这告诉 Aurelia 寻找 test-component.html 和 test-component.js。
我认为您也可以将该类重命名为“Testcomponent”。
Aurelia 是约定优于配置,因此您需要了解约定。
控制台没有任何错误消息吗?
关于javascript - 自定义组件/模板未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55995181/