【问题标题】:No Aurelia APIs are defined for the element:没有为元素定义 Aurelia API:
【发布时间】:2019-02-17 02:13:21
【问题描述】:

简介

所以我是第一次在 Aurelia 上工作,并收到了客户的一个项目。

据说 1 个月前一切正常,但现在我遇到了错误。

No Aurelia APIs are defined for the element: "O-SCHEMA-ACTION".

导致错误的行如下:

<o-schema-action show-as-popup.bind="false" repeat.for="a of actionGroup" 
item.bind="a" view-model.ref="this"></o-schema-action>

有人知道是什么原因造成的吗?

数组中有值actionGroup.

异常

aurelia-task-queue.js:56 Uncaught Error: No Aurelia APIs are defined for the element: "O-SCHEMA-ACTION".
    at getAU (aurelia-binding.js:5329)
    at Function.locateAPI (aurelia-binding.js:5356)
    at NameExpression.createBinding (aurelia-binding.js:5346)
    at applyInstructions (aurelia-templating.js:2467)
    at ViewFactory.create (aurelia-templating.js:2682)
    at BoundViewFactory.create (aurelia-templating.js:2562)
    at Repeat.addView (repeat.js:269)
    at ArrayRepeatStrategy._standardProcessInstanceChanged (array-repeat-strategy.js:111)
    at ArrayRepeatStrategy.instanceChanged (array-repeat-strategy.js:35)
    at Repeat.itemsChanged (repeat.js:160)

...

index.js:116 Uncaught Error: Uncaught Error: No Aurelia APIs are defined for the element: "O-SCHEMA-ACTION".
    at window.onerror (index.js:116)

HTML

<template>
    <c-page data-label.bind="action.groupLabel | humanize">
        <c-form>
            TESTING

            <o-form-schema action-controller.bind="actionController" root.bind="root" action.bind="action" filter-by="name !=='results'">

                <c-actions>
                    <li>
                        <button as-element="c-trigger" data-decorator="d-as-button t-error-dark-boxed" click.delegate="cancel()">CANCEL</button>
                    </li>

                    TODO: ISSUE HERE WITH BUTTONS
                    <o-schema-action show-as-popup.bind="false" repeat.for="a of actionGroup" item.bind="a" view-model.ref="this"></o-schema-action>

                </c-actions>

            </o-form-schema>

        </c-form>
    </c-page>
</template>

TypeScript / JS

export class Action {

     @bindable actionGroup = null;
   @bindable action = null;
        groupId = null;
        @bindable root = null;



    constructor() {}

    determineActivationStrategy() {
        return activationStrategy.invokeLifecycle;
        }

 cancel() {

    }

    activate(params, routeConfig) {
        this.groupId = params.id;
        Configuration.load().then(ret => {

            let clone = JSON.parse(JSON.stringify(ret));
            this.root = clone;
            this.actionGroup = this.buildGroup(clone.actions, this.groupId);
            this.action = this.actionGroup[0];
        });
    }

    buildGroup(actions, groupId) {
        let ret = actions.filter(a => CONDITION );
        ret.forEach(a => {
            // NOT RELEVANT TO SHOW THIS ( it works ) ... 
        });
        return ret;
    }


}

【问题讨论】:

    标签: javascript typescript aurelia


    【解决方案1】:

    初步回答

    我刚刚注意到...

    一个月前我们有两个文件:

    o-schema-action.js
    

    o-schema-action.html
    

    这些文件似乎已被删除。

    更新

    我刚刚又遇到了这个错误:

    No Aurelia APIs are defined for the element: "AB-SELECTOR".
    

    当缺少特定元素的文件时,似乎会引发此错误。

    【讨论】:

    • 这是一个基于cli 的项目吗? (我认为不是,因为您有运行时错误而不是构建时错误)您的模板在调用 &lt;o-schema-action ...&gt;&lt;/o-schema-action&gt; 时正在使用此组件。你能恢复那些文件吗?
    猜你喜欢
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    • 2018-03-27
    • 2015-03-28
    • 2017-11-22
    • 2015-08-07
    • 2018-09-18
    • 1970-01-01
    相关资源
    最近更新 更多