Aurelia要求html导入不起作用

chr*_*ark 1 html javascript aurelia

我在控制台中没有错误.但是控制台没有记录console.log我放入的构造函数top-nav.js.但更重要的是.简单的jumbotron div没有呈现,Aurelia在控制台中说它发现了正确的top-nav.html.这里是App.html

<template>
    <require from="bootstrap/css/bootstrap.css"></require>
    <require from="htmlreq/top-nav"></require>
    <h1>${message}</h1>
</template>
Run Code Online (Sandbox Code Playgroud)

App.js 为了一致性

export class App {
    message = "Hello Pathways";
}
Run Code Online (Sandbox Code Playgroud)

top-nav.html

<template>
    <div class="jumbotron">
        <div class="container"> 
            <p>Career &amp; Technical Education </p>
        </div>
    </div>
</template>
Run Code Online (Sandbox Code Playgroud)

top-nav.js控制台语句未触发.并且在大教堂的任何地方都没有看到或列出超大按钮.

export class TopNav {
    _topnav = true;
    constructor() {
        console.log('constructed');
    }
}
Run Code Online (Sandbox Code Playgroud)

Fab*_*Luz 5

您"需要"自定义元素但您没有"使用"它.

你应该做这个:

<template>
    <require from="bootstrap/css/bootstrap.css"></require>
    <require from="htmlreq/top-nav"></require>
    <h1>${message}</h1>

    <top-nav></top-nav>
</template>
Run Code Online (Sandbox Code Playgroud)

compose在这种情况下无需使用.