Aurelia:未捕获错误:doSomething不是一个函数

问题描述 投票:2回答:1

我有一个非常基本的Aurelia应用程序的问题。单击按钮,它表示找不到doSomething功能。其他组件中的其他按钮工作正常。显然我在这里做了一些根本错误的事情?

app.html:

<template>
    <require from="bootstrap/css/bootstrap.css"></require>
    <require from="./styles.css"></require>
    <require from="./client/person-details.html"></require>

    <person-details></person-details>
</template>

人,details.html

<template>
    <button click.delegate="doSomething()">clickey</button>
</template>

人,details.js

export class PersonDetails {
    doSomething() {
        console.log("Doing something");
    }
}
javascript binding aurelia
1个回答
7
投票

您目前只导入person-details的HTML,而您应该导入JS和HTML部分(通常由Aurelia自动完成,如果您省略文件扩展名)。

<require from="./client/person-details.html"></require>

应该

<require from="./client/person-details"></require>

© www.soinside.com 2019 - 2024. All rights reserved.