【问题标题】:Aurelia: Uncaught Error: doSomething is not a functionAurelia:未捕获的错误:doSomething 不是函数
【发布时间】:2017-06-20 13:38:23
【问题描述】:

我在使用非常基本的 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>

person-details.html

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

person-details.js

export class PersonDetails {
    doSomething() {
        console.log("Doing something");
    }
}

【问题讨论】:

    标签: javascript binding aurelia


    【解决方案1】:

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

    &lt;require from="./client/person-details.html"&gt;&lt;/require&gt;

    应该是

    &lt;require from="./client/person-details"&gt;&lt;/require&gt;

    【讨论】:

      猜你喜欢
      • 2021-05-25
      • 1970-01-01
      • 1970-01-01
      • 2016-03-21
      • 2017-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多