Chu*_*Nam 11 javascript aurelia
我有一个名为custom-element的自定义元素,我把它放在模板A中(带有控制器A)

export class CustomElem {
@bindable onCompleted;
........
}
Run Code Online (Sandbox Code Playgroud)
而updateDescription()是控制器A的一个功能.
export class A {
updateDescription(){
....
}
}
Run Code Online (Sandbox Code Playgroud)
如何使用custom-element调用updateDescription()?
Jer*_*yow 22
使用callbinding命令提供对自定义元素的函数调用的引用:
<custom-element on-completed.call="updateDescription()"></custom-element>
Run Code Online (Sandbox Code Playgroud)
要updateDescription使用参数调用方法,可以执行以下操作:
export class CustomElem {
@bindable onCompleted;
...
fooBarBaz() {
var args = {
something: 'A',
somethingElse: 'B',
anotherArg: 'C'
};
this.onCompleted(args);
}
}
Run Code Online (Sandbox Code Playgroud)
<custom-element on-completed.call="updateDescription(something, somethingElse, anotherArg)"></custom-element>
Run Code Online (Sandbox Code Playgroud)
export class A {
updateDescription = () => {
};
}
Run Code Online (Sandbox Code Playgroud)
然后
<custom-element on-completed.bind="updateDescription"></custom-element>
Run Code Online (Sandbox Code Playgroud)
内部CustomElem通话this.onCompleted()
| 归档时间: |
|
| 查看次数: |
3635 次 |
| 最近记录: |