javascript - 自定义组件/模板未显示

标签 javascript aurelia

在使用 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/

相关文章:

javascript - 对数字上的 sails 水线进行排序

javascript - 在 Aurelia 中用模板本身替换自定义元素(而不是将其包含在自定义元素中)?

typescript - 使用 fetch api 处理 500 响应

node.js - Aurelia bundle 和 jspm 配置文件

javascript - 模块和脚本有什么区别?

javascript - 来自两个实体集的 xml View 绑定(bind)数据

javascript - 倒计时达到 0 时发出蜂鸣声

javascript - 如何将网站语言转换为用户选择的语言 - React JS

typescript - 更改集合时不会触发 Aurelia CollectionObserver 处理程序

asp.net-core - Visual Studio 2015 中的 Aurelia 项目设置和文件夹结构 : what goes in wwwroot?