Aurelia.js 中的 compose 有活动吗?
Does compose in Aurelia.js have an events?
我很想知道有没有一种方法可以绑定到 compose 属性的一些回调是 Aurelia.js。
我正在尝试做类似的事情
view.html
<a click.delegate="changeTab('first')">Tab 1</a>
<a click.delegate="changeTab('second')">Tab 2</a>
<a click.delegate="changeTab('third')">Tab 3</a>
<compose view-model.bind="tab"></compose>
在每个选项卡上,我在 attached
事件
中都有相同的代码
first.js
import {inject} from 'aurelia-framework';
@inject(Element)
export class First {
constructor(element) {
this.element = element;
}
attached() {
$(this.element).find('code').each(function () {
Prism.highlightElement($(this)[0]);
});
}
}
问题是
<compose>
是否有我可以绑定的类似事件?我是说
view.html
<compose view-model.bind="tab" attached.bind="composeAttached()"></compose>
这样做的 "Aurelia way" 是:
import {inject, customAttribute} from 'aurelia-framework';
@customAttribute('syntax-highlight')
@inject(Element)
export class SyntaxHighlight {
constructor(element) {
this.element = element;
}
attached() {
Prism.highlightElement(this.element);
}
}
<pre><code syntax-highlight>...</code></pre>
我很想知道有没有一种方法可以绑定到 compose 属性的一些回调是 Aurelia.js。
我正在尝试做类似的事情
view.html
<a click.delegate="changeTab('first')">Tab 1</a>
<a click.delegate="changeTab('second')">Tab 2</a>
<a click.delegate="changeTab('third')">Tab 3</a>
<compose view-model.bind="tab"></compose>
在每个选项卡上,我在 attached
事件
first.js
import {inject} from 'aurelia-framework';
@inject(Element)
export class First {
constructor(element) {
this.element = element;
}
attached() {
$(this.element).find('code').each(function () {
Prism.highlightElement($(this)[0]);
});
}
}
问题是
<compose>
是否有我可以绑定的类似事件?我是说
view.html
<compose view-model.bind="tab" attached.bind="composeAttached()"></compose>
这样做的 "Aurelia way" 是:
import {inject, customAttribute} from 'aurelia-framework';
@customAttribute('syntax-highlight')
@inject(Element)
export class SyntaxHighlight {
constructor(element) {
this.element = element;
}
attached() {
Prism.highlightElement(this.element);
}
}
<pre><code syntax-highlight>...</code></pre>