【问题标题】:CustomAttribute looking for html寻找 html 的 CustomAttribute
【发布时间】:2015-06-19 07:30:00
【问题描述】:

我正在尝试根据CustomAttribute 约定在 Aurelia 中构建自定义属性。但是,当我尝试在视图中使用它时,使用<import from='./shared/tr'></import>,aurelia 会尝试在同一路径中查找tr.html

正是我在这里缺少的东西?

编辑: tr.js 如下所示:

import aur = require("aurelia-framework");

export class TrCustomAttribute {

    public element;
    static inject = [Element];

    constructor(element) {
        this.element = element;        
    }

    bind() {
       console.log(this.element);
    }

    valueChanged(newValue) {
        if (newValue) {
            console.log(newValue);
        }
        console.log(this.element);

    }
}

我正在尝试使用如下属性:

<import from='./shared/tr'></import>
<button class="btn btn-primary" tr="something"> Something </button>

【问题讨论】:

    标签: aurelia custom-attribute


    【解决方案1】:

    我相信您正在寻找 &lt;require from='./shared/tr'&gt;&lt;/require&gt; 而不是导入。我犯了几次同样的错误,但仍然错过它:)

    【讨论】:

    • 我试过了,但在这种情况下,甚至没有从浏览器请求 tr.js 文件。
    • tr.js 长什么样子?是不是像custom attribute in aurelia not working
    • 请检查我在问题中所做的编辑。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-11
    • 1970-01-01
    • 2011-10-18
    • 2017-07-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多