2015-06-19 33 views
0

我想根据CustomAttribute惯例在Aurelia中建立一个自定义属性。但是,当我尝试在视图中使用它时,使用<import from='./shared/tr'></import>,aurelia会尝试在同一路径中查找tr.htmlCustomAttribute寻找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> 

回答

1

我相信你正在寻找<require from='./shared/tr'></require>而不是进口。我犯了同样的错误几次,仍然错过了:)

+0

我试过了,但在这种情况下,tr.js文件甚至没有从浏览器请求。 –

+0

tr.js是什么样子?是否像[aurelia中的自定义属性不工作](http://stackoverflow.com/questions/29680191/custom-attribute-in-aurelia-no-working) –

+0

请检查我在问题中所做的编辑。谢谢。 –