Javascript 在Aurelia应用程序中正确使用dispatchEvent
我有以下自定义元素:Javascript 在Aurelia应用程序中正确使用dispatchEvent,javascript,aurelia,Javascript,Aurelia,我有以下自定义元素: <template> <div class="input-group"> <div class="input-group-addon left">${groupAddonLeftText}</div> <input type="text" autocomplete="off" class="form-control big left-addon right-addon" id="address" valu
<template>
<div class="input-group">
<div class="input-group-addon left">${groupAddonLeftText}</div>
<input type="text" autocomplete="off" class="form-control big left-addon right-addon" id="address" value.bind="value & debounce">
<div class="input-group-addon right">
<span class="icon ${iconClass}"></span>
</div>
<div class="auto-complete-wrapper ${showSuggestions ? 'open': ' '}">
<ul>
<li repeat.for="suggestion of suggestions">
<div click.delegate="selectSuggestion(suggestion)">
<p>
<strong>${suggestion.street}</strong>
</p>
<p>${suggestion.city}</p>
</div>
</li>
</ul>
</div>
</div>
</template>
我正在html中应用自定义元素:
<autocomplete remove.delegate="remove()" selected.delegate="calculatePrice()"></autocomplete>
并在此基础上创建了\u disptachSelectEvent
方法
另请参见此要点:只需稍加调整(在calculatePrice()函数中添加this.
),您的要点运行良好:
你能提供一个重现你问题的要点吗?你可以把这个要点作为基础。我有一些想法,但我必须测试them@FabioLuztnx!查看我的更新(在calculatePrice()
函数中添加this.
),您的要点运行良好:是的,它对我有用@AshleyGrant我想你可以把你的评论作为一个答案发布。Tnx@AshleyGrant尽管这足以让我的要点发挥作用,但这段代码并没有在我的应用程序中运行。我已经更新了我的要点,使之与我的申请书一模一样;仍在gist中工作,但不在应用程序中。
<autocomplete remove.delegate="remove()" selected.delegate="calculatePrice()"></autocomplete>
export class App {
message = 'Hello World!';
calculatePrice(){
this.message = "calculatedPrice!"
}
}